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 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, when I run the same code I now get an error saying _malloc is not defined:
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!!