- Home /
Web player loading progress "first"
I am trying to check if the web player is loaded in the browser itself. I was looking at the documentation here http://docs.unity3d.com/Documentation/Manual/WorkingwithUnityObject.html while trying to figure out how to check if the game has loaded. I noticed that the "first" under "pluginStatus", and thought that would indicate the first frame after the game has loaded. Well, it says "called after the plugin have been installed at the first frame of the game is played (This will not be called if the plugin was already installed previously) ", which sounds like it will only use "first" if the plugin (and by that I assume either the game or the webplayer plugin) was previously installed, they won't call "first". But through all my tests, "first" is called every first frame of every load of my app. I tried this in both a debug build and release build, and both times, first is called. I launched the same html 3 times all at once, and first was called every time.
So is it safe to assume that the documentation is terrible, and that first actually does indicate the first frame of the app after loading every time?
Answer by Bunny83 · Jan 15, 2013 at 10:13 PM
As example, here's a script i wrote ages ago. It will read the URL of the webpage the webplayer is loaded in:
using UnityEngine;
using System.Collections;
public class URLParameters : MonoBehaviour
{
public static bool HaveInformation = false;
public static string Href;
public static string Hash;
public static string Host;
public static string Hostname;
public static string Pathname;
public static string Port;
public static string Protocol;
public static string Search;
public void Start()
{
if (Application.isWebPlayer)
Application.ExternalEval ("GetUnity ().SendMessage ('"+gameObject.name+"', 'SetAddressComponents', location.href +'|'+ location.hash +'|'+ location.host +'|'+ location.hostname +'|'+ location.pathname +'|'+ location.port +'|'+ location.protocol +'|'+ location.search);");
}
public void SetAddressComponents (string aData)
{
string[] parts = aData.Split('|');
Href = parts[0];
Hash = parts[1];
Host = parts[2];
Hostname = parts[3];
Pathname = parts[4];
Port = parts[5];
Protocol = parts[6];
Search = parts[7];
HaveInformation = true;
}
}
Inside Unity "HaveInformation" can be used to check if the information has arrived. Of course it might be a good idea to implement a timeout in the event the user disabled Javascript in the browser of any other problem that prevents the JS to return the information.
Answer by Bamboy · Jan 15, 2013 at 08:58 PM
Are you looking for MonoBehaviour.OnLevelWasLoaded?
No. I am trying to send information from the web browser to the web player, but have to wait until everything is loaded.
Hm.. I'm not sure about that. If something like that exists I have a feeling it would be under Application. http://docs.unity3d.com/Documentation/ScriptReference/Application.html
You are thinking in the reverse. Application is used to have the web player tell the web browser something. I am getting the web browser to tell the web player something. And I can, using u.getUnity().Send$$anonymous$$essage in the Javascript of the generated html page.
And what's the actual problem? Your Webplayer just executes a Javascript function in the browser's HT$$anonymous$$L page which can then send information back to the webplayer...
btw. To me the documentation is pretty clear about "first". "first" is listed under "plugin status". If you take a look at the other 3 members :
unsupported
missing
installed
It should be clear that "first" has nothing to do with your game or any content that will be loaded into the plugin. It is the state of the webplayer plugin itself.
To quote the docs:
"first" (is) called after the plugin have been installed at the first frame of the game is played (This will not be called if the plugin was already installed previously)
Your answer
![](https://koobas.hobune.stream/wayback/20220613091008im_/https://answers.unity.com/themes/thub/images/avi.jpg)