Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to pass a parameter from web browser to Unity3D web player as soon as it is loaded. I know that, as soon as the web-player is loaded, the start() function is execute inside web-player. So I want to pass parameter from web browser to this start() function.

share|improve this question
    
Where exactly is the parameter coming from? The HTML code somewhere? HTML isn't going to "pass" anything, but perhaps Unity could retrieve it. If we know where you want to get it from, that would help. –  Byte56 Jul 23 '13 at 21:54
add comment

2 Answers

up vote 3 down vote accepted

The documentation you need is here: http://docs.unity3d.com/Documentation/Manual/UnityWebPlayerandbrowsercommunication.html

If you are able to control when you call Start(), eg. because that object isn't immediately created, then you can use the getUnity().SendMessage route to send in the parameters from the web page.

Otherwise, you might want to embed an Application.ExternalCall() into your Start() function to call out to a Javascript function in the web page, which can return the parameters you need.

share|improve this answer
    
Thank you very much... –  Tharindu Jul 23 '13 at 22:23
add comment

This one was worked well. (then automatically read parameters from html page as soon as web-player is loaded, this method is good for read the URL parameters)

inside html->

function OnUnityReady()
{

    u.getUnity().SendMessage("GameObject", "myTest", GET.Use_id);
}

inside unity3D C# code ->

void Start()

{

Application.ExternalCall("OnUnityReady");

}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.