- Home /
The question is answered, right answer was accepted
Is there a way to get the page that my WebPlayer is embedded into?
As the question says, is there a way of getting the html file that contains the webplayer embedded without knowing the name of the file? I know you can use Application.dataPath and Application.absoluteURL to get the path to the folder and the player data file respectively (I have made some tests) but I don't know if there's a method to get the actual file. Any ideas?
Thanks in advance.
[Edit] Besides parsing some parts of the html code (see comment to the answer by @brianturner) I think it can be useful to perform a connection check as in this answer, but made from a webplayer.
Answer by Andres-Fernandez · Mar 31, 2015 at 06:35 AM
So, yeah. A long time has passed since I asked this question, but I've just come across the solution. It was explained a year ago by @bernardfrancois at the forum here and also better explained in a blog post here. So all credit goes to him.
It looks like you can access the LocationObject using UnityObject2.instances[0], and by accessing the LocationObject you have access to all the url stuff you may need (href, pathname, search, you name it). Again, credit to @bernardfrancois.
Answer by steakpinball · Oct 02, 2014 at 02:43 PM
I haven't tried it, but have you looked into using javascript running in the web page and sending that information back into your player? http://docs.unity3d.com/Manual/UnityWebPlayerandbrowsercommunication.html
Thanks for the response. Yes, I've thought of that (actually I make use of the ExternalCall function often to communicate with the page in other projects). But that's exactly what I want to know if it's avoidable.
In this case it's a simple problem, I just want to know whether the html tag has a "lang" attribute to detect the language of the page and set the default language of my game. So I need a way to get the html file (in case there is way).
As plan B, I'm already working in the usual communication with the page using the ExternalCall.