Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by DoctorWhy · Jan 15, 2013 at 08:46 PM · webplayerprogress

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bamboy · Jan 15, 2013 at 08:58 PM

Are you looking for MonoBehaviour.OnLevelWasLoaded?

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DoctorWhy · Jan 15, 2013 at 09:00 PM 0
Share

No. I am trying to send information from the web browser to the web player, but have to wait until everything is loaded.

avatar image Bamboy · Jan 15, 2013 at 09:09 PM 0
Share

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

avatar image DoctorWhy · Jan 15, 2013 at 09:11 PM 0
Share

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.

avatar image Bunny83 · Jan 15, 2013 at 10:04 PM 0
Share

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...

avatar image Bunny83 · Jan 15, 2013 at 10:19 PM 0
Share

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)

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

IsLoaded function for Browsercommunication? 1 Answer

Webplayer loading-progress 0 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Unity Web Player in Facebook: How to set the application name ? 1 Answer

Webplayer not recognized in IE and Facebook 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges