We can modify the webplayer’s behavior using custom tags… but is it possible to get the value of those tags Unity-side (ie inside the webplayer)?
I guess one could use browser-javascript to get those tags, but is there a more direct (and elegant) way?
In my game I have a fullscreen button, but I don’t want to show it if fullscreen has been disabled by tags… of course I can make a special build, but again: not elegant !
Also, I could use tags to configure a few game options in PHP, which would save using SendMessage (which relies on the browser allowing javascript)…
No, the only object/embed tag value you can read directly is the src tag (using Application.srcValue). With that in mind here are the options as I see 'em:
As you mentioned, use browser-based JS to get the information and message that back into your content.
If you really just want to know this one parameter’s value then perhaps you can modify the src URL a bit and parse it from there? For example, make your src value something like “yourfile.unity3d?fs=true”. Then in your content you read the src value and parse out the fs (“full screen”) value and go from there.
In either case no special build is necessary, but you will have to do some page and/or tag modifying.
Edit: Oh, and FYI, you might be able to devise routines here using entirely ExternalEval (no function calls which then use SendMessage to send back the data). It will require you to have a GetUnity() type function in the page, but then in one line you could get at any parameter value you’d like and avoid using SendMessage.
URL params wouldn’t be wise in my case because the user can just edit them and that’s baaad.
The other options rely on ExternalEval or SendMessage, so either way on browser-JS being turned on… I don’t really like it but then again it’s my (aging) webdev reflexes talking.
Have you any idea as to the JS penetration these days? (or rather, the percentage of people that do turn it off)
I think you’ve misunderstood my suggestion. I was not suggesting that you read the page’s URL and parameters it contains (which the user could modify with ease). Instead I was suggesting that you read the object/embed tag’s src parameter, and pull any needed information from its value.
You originally asked if you could read arbitrary object/embed tag parameter values without using browser-based JS, the answer is no and that from within your content you can only read the src parameter’s value. So modify the src parameter value and use that to pass information in the same, non-user editable way as you would any other parameter value.
Oh yes indeed I misunderstood, sorry!
Your approach is very clever, I didn’t think you could modify the src in that way, but like all good tips now that you pointed it out it seems so obvious, thanks a lot !
I think I’ll even repeat the disableFullscreen attribute in this fashion, it’s a bit redundant but it gets the job done without any browser-JS… sweet!