How do I pass variables from javascript to webplayerin NaCl


I am trying to pass a username from the browser to the Unity game in Native Client. In the standard webplayer, I accomplished this by appending the username to the html path and reading it using Application.srcValue() as suggested here, but this doesn’t work in NaCl.

The documentation says to use the following function call:


Can someone provide more details and/or sample code for both the webpage and the corresponding Unity? I have done a fair amount of Unity development but I’m a JS newbie.

It turns out that this line needs to be added to the generated manifest.json:

"content_security_policy": "script-src 'unsafe-eval'; object-src 'self'",

Then, you can use this following command to call a function from a script attached to a GameObject:


GameObject is the name of a GameObject in your scene and Message() is the name of a function in a script attached to the object (you don’t specify the name of the script anywhere).