Loading external variables via SendMessage into Unity WebPlayer

if (typeof unityObject != "undefined") {
    unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", 600, 450);
    SaySomethingToUnity();
}

Above is the autogenerated javascript calling a function linked below.

I am trying to pass a text string to unity webplayer using SendMessage - basically, the function SaySomethingToUnity() sends a message to Unity webplayer from javascript.

But.. The text doesn't load. I wonder why..

Is there a way to detect if the Unity webplayer content has finished downloading first before calling `SaySomethingTOUnity()`?

The best way to do that is to have the Unity game use a webpage callback when it's loaded.

In Unity:

Application.ExternalCall("OnUnityReady")

In the webpage:

function OnUnityReady() { SaySomethingToUnity(...); }

That way, you can be sure that Unity is fully loaded and ready to accept your message.

Look for the GetUnity() function in the auto-gen html, use that to access the player.

Worst case, you can have your first scene send a message out to the HTML via Application.ExternalCall() to signal that it's been loaded.