Hi all,
I'm working on a webGL project and I have a function where I send a JSON array from an external javascript to the unity player. I followed the instructions [in the Unity 5.6 manual][1] using `lengthBytesUTF8` and `_malloc` like so:
//my_external_javascript.js
var my_global_array = ["my", "array", "data"];
function UnityGetMarkerArray()
{
var returnStr = JSON.stringify(my_global_array);
var buffer = _malloc(lengthBytesUTF8(returnStr) + 1);
writeStringToMemory(returnStr, buffer);
return buffer;
}
This worked great.
**Then I upgraded to Unity 2017.**
Now even though [the manual entry is largely unchanged][2], when I run the same code I now get an error saying _malloc is not defined:
![_malloc is not defined][4]
I can see that now `_malloc` and `lengthBytesUTF8` are no longer defined anywhere, and I can't seem to get them back.
Is this a bug in the newest version of 2017? Could anyone perhaps provide me with replacement functions so I can keep working? Thanks!!
[1]: https://docs.unity3d.com/560/Documentation/Manual/webgl-interactingwithbrowserscripting.html
[2]: https://docs.unity3d.com/2017.1/Documentation/Manual/webgl-interactingwithbrowserscripting.html
[4]: /storage/temp/100002-chrome-2017-08-16-11-51-08.png
↧