Buffer created with 'stringToUTF8()' is empty when received on unity's side (5.6.2f1)

Hi :slight_smile:
I’m using the latest unity version (5.6.2f1) with a native WebGL js plugin + some custom code I added in the generated ‘index.html’ file.
For some reason, when returning a string value (by allocating a buffer and using the ‘stringToUTF8’ function), the received string is always empty when receiving it on unity’s side :face_with_spiral_eyes:
This used to work in the previous version I used (5.4.2f2).

Here is the code I use (in index.html):

function ReturnString()
{
var returnStr = ‘A string from index.html!’;
var buffer = gameInstance.Module._malloc(gameInstance.Module.lengthBytesUTF8(returnStr) + 1);

gameInstance.Module.stringToUTF8(returnStr, buffer,gameInstance.Module.lengthBytesUTF8(returnStr) + 1);

return buffer;
}

For some reason, the ‘buffer’ pointer is not received correctly on Unity’s side, and is empty.
Again, this used to work in Unity 5.4.2f2 (besides the ‘gameInstance.Module’ prefix which is needed for Unity >= 5.6)

Thanks for your help ;):wink:

Anyone? These prevents me from working on my webgl build:(

Ok, I did a silly mistake, forgot to return the value in the js plugin:hushed::hushed::hushed::face_with_spiral_eyes::face_with_spiral_eyes::face_with_spiral_eyes:
Working great