Passing web parameters into Unity

Is there a way to pass parameters from a web site into a unity web based application ?

http://unity3d.com/support/documentation/Manual/Unity%20Web%20Player%20and%20browser%20communication.html

–Eric

1 Like

Thanks Eric !!

Or! You might also consider adding parameters on to the src URL for your *.unity3d file, then parsing those within your game. For example, instead of this:

src=myFile.unity3d

Use this:

src=myFile.unity3d?foo=hello

Then inside of your game check Application.srcValue and strip/parse everything after the question mark. Note that this may trigger fresh downloads of your *.unity3d file as unique data means a unique URL which means a fresh download, but it might work in some cases so consider it a possibility.

This is a good prompt for me, I have a great example already in place of how you can use “deep linking” to by default go to a specific level within Unity. For example, go here:

http://files.unity3d.com/tom/DeepLinking/

That loads Level 0, just a simple menu, no characters. Press the buttons though, notice how doing that appends a # to the end of the URL? Bookmark one of those URLs, or just load this instead:

http://files.unity3d.com/tom/DeepLinking/#Penelope

Now notice that it loads that level by default! Two way browser communication at work, passing of parameters at work, etc. I gotta get a blog post up on that ASAP. It uses the APIs discussed at the URL Eric provided above, not my second suggestion.

i was looking how to do this, it is kind of confusing i must add, but that is probably because i dont understand it :slight_smile:
i was looking into how to pass some parametars to the unity so that i can start player with something like this:

something similiar to the link to the location in the google maps.
so when the player is loaded it can zoom certain location…

there are numerous ways to do it in the forums, i am looking the easiest one that will not involve changing html that unity2.6 produced
(at least to much, because it might brake some other things)

thanks to everybody that is willing to look into this and point me in the right direction!

thank you

@HiggyB it seems that your example does not work in google chrome, it does not load character

I’ve been looking into this myself and found no immediately working solution on the forums or through google, so created something myself.

The RequestParameters class, made available for anyone to use on my company’s blog, does the trick. It’s my little New Year’s present to the community :slight_smile:
previewlabs.com/reading-url-parmeters-from-web-player-builds

Simply add it to any GameObject in your scene, and call the string GetValue(string key) method.

[edit]
Note that Application.srcValue and Application.absoluteURL don’t contain anything past the “.unity” bit in the file name - just tried it in Unity 4.3 in a web player build.

@HiggyB: the deep linking examples you created don’t seem to work any more with current the Web Player plugin. Did you end up writing your blog post about this?
[/edit]