Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Browser to Unity communication with WebGL

Discussion in 'Unity 5 Pre-order Beta' started by Orbcreation, Dec 15, 2014.

  1. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    There are the functions Application.ExternalCall and Application.ExternalEval, that still seem to work fine in WebGL. Great!

    But now the other way around:
    In the WebPlayer you can use the following to send a message to a Unity object:
    u.getUnity().SendMessage("MyObject", "MyFunction", "Hello from a web page!");

    Is there a similar function in the WebGL implementation? And if so, how do I call it?
     
  2. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    Never mind. Sorry. I looked in the wrong manual version. It's very simple:
    call SendMessage ('MyGameObject', 'MyFunction', 'foobar'); from the webpage.

    There are actually even much better ways available now. Look in the manual for the page: WebGL: Interacting with browser scripting
     
  3. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    There are better ways instead of `Application.ExternalCall` and `Application.ExternalEval`, yes. But what alternatives are there for `SendMessage`?

    BTW, you might be interested in this thread, if you talking about jslibs.