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 :
A sample code is like this:
The method within unity player is like this:
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.
asked Feb 15 '11 at 01:46 AM
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.
Getting another script, where otherscript is the name of the script you are sending the stuff to.
If other script is attached to same object can just do.
Or if you want to get it off a specific gameobject
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.