Problem sending array to unity player using SendMessage

Hi,

I am trying to call the SendMessage function in order to call a method within unity player from web browser and I want to pass an array of integers or array of bytes. It works only if the length of the array is less than 1024. When the length of the array goes more than 1024 then I receive :

Error calling method on NPObject!

A sample code is like this:

var a = new Array();
var i = 0;
for (i = 0; i < 1025; i++) {
   a *= i;*
*}*
*unity.SendMessage("MyObject", "MyMethod", a);*
*```*
*<p>The method within unity player is like this:</p>*
*```*
*void MyMethod(Array array)*
*{*
 *Debug.Log("received array length : " + array.Length);*
*}*
*```*
*<p>As I mentioned everything works as expected until the length of the array will be more than 1024. However if I pass a string it could be very long. I tested a string with length 1,000,000 and it worked. Unfortunately in my case I need the array and converting the string back to array will significantly affect the performance.</p>*
*<p>Any idea?</p>*

I was going to write this as a comment but got to long.

The fact it's the magic number of 1024 I'm going to assume it's just a engine problem with either SendMessage or Array.

So how many components are you sending this to? Seems kind of poorly designed/inefficient if you ask me if you need to send such a large amount of data to a large number of places. If it's just a single other script you should really just get a direct reference to it.

Also out of interest, if you encapsulate the array it in another class and send the class does it still cause the same issue?

Finally, have you considered trying an ArrayList instead? Or just a basic native .NET arrays if you don't need to resize it (assuming above code isn't what is in your game.) I don't really like the built in Unity Array.

-edit-

Getting another script, where otherscript is the name of the script you are sending the stuff to.

OtherScript other = FindObjectOfType(typeof(OtherScript));
other.MyMethod(a);

If other script is attached to same object can just do.

GetComponent(OtherScript).MyMethod(a);

Or if you want to get it off a specific gameobject

var go = GameObject.Find("SomeGuy");
go.GetComponent(OtherScript).MyMethod(a);

You shouldn't do a Find every update for performance reasons, but you can do it once in Start() and just store it and call it anytime you want.