Cant pass gameObject.Name to javascript plugin

Hello,

I wrote a short javascript plugin and I want to pass my gameobjects name from c# to the javascript plugin so that the plugin can send back a result to my gameobject.

However no matter what I do, the name of the gameObject gets trashed when it gets to the javaScript plugin, but other strings are ok for some reason.

Here is my plug in code:

var MyPlugin = {
Test: function (go,str) {
console.log(go);
console.log(str);
}
};
mergeInto(LibraryManager.library, MyPlugin);

Here is the code to call it from c# inside unity

[DllImport(“__Internal”)]
private static extern string Test(string url,string objectName);

public void Func()
{
string var1=“hello”;
Test(gameObject.name,var1);
}

The string variable var1 prints “hello” but the gameobject’s name just prints a random set of numbers instead of the gameobjects name, I tried using Pointer_stringify(go), but then it just prints a bunch of garbage characters.

I even reversed the order of the parameters thinking maybe i can only pass one parameter, but that had the same result.

Anybody knows whats wrong?

I think you should convert the string via Pointer_stringify. Have a look at HelloString() example in the manual.