/// <summary> /// Initialise this player /// </summary> void Start () { //Initialise this object in map Vector3 initialPosition = new Vector3 (UnityEngine.Random.Range (-10, 10), 5, (UnityEngine.Random.Range (-10, 10))); firebase = Firebase.CreateNew ("https://gdg2015.firebaseio.com/"); firebase.UnAuth (); firebase.AuthAnonymously ((AuthData auth) => { InitFirebasePlayer(auth.Uid,initialPosition); }, (FirebaseError e) => { Debug.Log ("auth failure!! "+e); }); //Listeners firebase.ChildAdded += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Add(e.DataSnapshot)); }); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Remove(e.DataSnapshot)); }); }; firebase.ValueUpdated += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Modify(e.DataSnapshot)); }); }; }
/// <summary> /// Initialise this player /// </summary> void Start() { //Initialise this object in map Vector3 initialPosition = new Vector3(UnityEngine.Random.Range(-10, 10), 5, (UnityEngine.Random.Range(-10, 10))); firebase = Firebase.CreateNew("https://gdg2015.firebaseio.com/"); firebase.UnAuth(); firebase.AuthAnonymously((AuthData auth) => { InitFirebasePlayer(auth.Uid, initialPosition); }, (FirebaseError e) => { Debug.Log("auth failure!! " + e); }); //Listeners firebase.ChildAdded += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Add(e.DataSnapshot)); }); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Remove(e.DataSnapshot)); }); }; firebase.ValueUpdated += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Modify(e.DataSnapshot)); }); }; }