WebGL javascript functions

I’ve added an WebGL plugin “*.jslib” to my project to get access to some javascript methods.

one of thoose methods:

 WindowLocationHash: function(){
        return window.location.hash;
  },

I’ve “importet” it like this: [DllImport("__Internal")] private static extern string WindowLocationHash()

but it returns always empty string. If i call the same javascript method from browser debug window i get the correct result.


Unity Personal 5.2.1f1

Thanks for all your response! Helped me very well, but i’ve got the final solution myself.

 WindowLocationHash: function()
{
    var x = window.location.hash; 
    var buffer = _malloc(x.length + 1);
    writeStringToMemory(x, buffer);
    return buffer;
},

As the documentation says

To return a string value you need to call _malloc to allocate some memory and the writeStringToMemory helper function to write a JavaScript string to it.

I’d highly recommend putting this in an seperate panel with a large exclamation mark