gameInstance.SendMessage(...)
and even that wasn’t available immediately on page load… I had to wrap it in a setTimeout
loop.
The standard WebGL template file was changed but I see no mention of this in any documentation or release notes.
I was able to call a function from my a gameobject in my scene from my javascript code.
My scene was loading very slow, even when I only have two gameobjects inside it.
And because I called my function “SendMessage” before the page finish loading, a pop up with the error “SendMessage is not defined” appears.
-The steps to solve it were:
1-The form to call the funtion is :
function SaySomethingToUnity(_parameter_To_Send)
SendMessage(“GameObject_To_Call”, “Function_To_Call”, _parameter_To_Send);
You DO NOT need to use "“u.getUnity()” anymore.
Remember that (SendMessage will then call the function Function_To_Call() on the game object named GameObject_To_Call, passing a piece of string, int or float, data as an argument:)
2-Disable thee Exceptions in Unity(PlayerSettings->Publishing Settings->Enable Exceptions: None). This form, my scene was loading faster.
3-When everything was loaded. The “SendMessage” error did not appears anymore (the file UnityConfig.js that Unity generated when building does not have a definition for the function SendMessage, so do not look for it).
I found the function defined of SendMessage in {YourGameProjectName}.js
It’s seems like this:
function SendMessage(gameObject,func,param
line 1,Col 536