vendredi 19 août 2016

Send message from Browser to Unity3D

I am trying to send a message to my Unity3D WebGl app.

The controller of my GameObject "Player" looks basically like this:

public class color : MonoBehaviour {

    void Start ()
    {
        gameObject.GetComponent<Renderer>().material.color = Color.red;
    }

    public void green(string s)
    {
        gameObject.GetComponent<Renderer>().material.color = Color.green;
    }
} 

and my Javascript method like this:

function SaySomethingToUnity() {
    SendMessage("Player", "green", "teeeext");
}

But when I call it nothing happens. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire