Search Unity

browser to unity communication

Discussion in 'Scripting' started by dansav, Apr 23, 2008.

  1. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    I am having some problems sending anything to my gameObject from the browser

    Here is the browser code in the body
    <input type=text id="sendme" value="hello">

    Here is the browser code in the script section
    function sendToUnity(){
    sendthis=document.getElementById("sendme").value
    getUnity().SendMessage("CSB","MyFunction",sendthis);

    }

    function fromUnity(data){
    eval(data);
    }
    </script>

    And on the unity side I have
    CSB is a game object
    attached is a script called worldsetup.js
    and inside that is


    function MyFunction(arg:String){
    Application.ExternalCall ("fromUnity", "alert('Hello from Unity')");
    }

    The call in MyFunction works fine outside of MyFunction..so it's not that.
    I don't think the call from the browser to Unity is working but I'm not sure why.
    I'm using Firefox

    Thanks,

    Dan
     
  2. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    I was using getUnity instead of
    GetUnity()

    works now.


    Dan