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)
{
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
I was having the error: “SendMessage not defined” when I was integrating unity3d using iframe. I switched to using webgl-template (Unity - Manual: WebGL templates) and added my SendMessage call there, that worked fine.