Exemple #1
0
    void InitializeFirebase()
    {
        FirebaseApp app = FirebaseApp.DefaultInstance;

        app.SetEditorDatabaseUrl("https://smallworld3d-2ac88.firebaseio.com/");
        //app.SetEditorP12FileName ("filebaseTest-2e653eef7319.p12");
        app.SetEditorServiceAccountEmail("*****@*****.**");
        //app.SetEditorP12Password ("2e653eef7319ed39d40ed0a6370d9d222bbb555a");

        _databaseReference = FirebaseDatabase.DefaultInstance.RootReference;

        Debug.Log("InitializeFirebase:  _databaseReference:" + _databaseReference);
    }
Exemple #2
0
    private void _initFirebase(System.Action callbackWhenDone)
    {
        FirebaseApp app = FirebaseApp.DefaultInstance;

        app.SetEditorDatabaseUrl("https://smallworld3d-2ac88.firebaseio.com/");
        //app.SetEditorP12FileName ("filebaseTest-2e653eef7319.p12");
        app.SetEditorServiceAccountEmail("*****@*****.**");
        //app.SetEditorP12Password ("2e653eef7319ed39d40ed0a6370d9d222bbb555a");

        //  _databaseReference = FirebaseDatabase.DefaultInstance.RootReference;

        // Debug.Log("InitializeFirebase:  _databaseReference:" + _databaseReference);
        if (GlobalVar.DEBUG)
        {
            DebugOnScreen.Log("InitializeFirebase done ....");
        }
        initiated = true;
        callbackWhenDone();
    }
Exemple #3
0
    // Initialize the Firebase database:
    void InitializeFirebase()
    {
        FirebaseApp app = FirebaseApp.DefaultInstance;

//		app.SetEditorDatabaseUrl ("https://testunityfirebase-197e9.firebaseio.com/");
//		//app.SetEditorP12FileName ("TestUnityFirebase-04484f3999fc.p12");
//		app.SetEditorServiceAccountEmail ("*****@*****.**");
//		//app.SetEditorP12Password ("notasecret");

        app.SetEditorDatabaseUrl("https://smallworld3d-2ac88.firebaseio.com/");
//		app.SetEditorP12FileName ("filebaseTest-2e653eef7319.p12");
        app.SetEditorServiceAccountEmail("*****@*****.**");
//		app.SetEditorP12Password ("2e653eef7319ed39d40ed0a6370d9d222bbb555a");

        _databaseReference = FirebaseDatabase.DefaultInstance.RootReference;

        //DebugLog ("_databaseReference 0000 " + _databaseReference);

//		leaderBoard = new ArrayList ();

        /*
         * leaderBoard.Add ("Firebase Top " + MaxScores.ToString () + " Scores");
         * FirebaseDatabase.DefaultInstance
         * .GetReference ("Leaders").OrderByChild ("score")
         * .ValueChanged += (object sender2, ValueChangedEventArgs e2) => {
         *      if (e2.DatabaseError != null) {
         *              Debug.LogError (e2.DatabaseError.Message);
         *              return;
         *      }
         *      string title = leaderBoard [0].ToString ();
         *      leaderBoard.Clear ();
         *      leaderBoard.Add (title);
         *      if (e2.Snapshot != null && e2.Snapshot.ChildrenCount > 0) {
         *              foreach (var childSnapshot in e2.Snapshot.Children) {
         *                      leaderBoard.Insert (1, childSnapshot.Child ("score").Value.ToString ()
         + "  " + childSnapshot.Child ("email").Value.ToString ());
         +              }
         +      }
         + };
         */
    }
Exemple #4
0
        /// <summary>
        /// Called once per frame.
        /// LeaderboardController's initialization and events are queued in its Database callback
        /// methods and then triggered in Update, because Firebase Database uses asynchronous
        /// threads in "ContinueWith" when results are retrieved, but many Unity functions such
        /// as modifying UI elements can only be called from the main thread.
        /// </summary>
        private void Update()
        {
            if (!initialized)
            {
                if (readyToInitialize)
                {
                    FirebaseApp app = FirebaseApp.DefaultInstance;
                    if (EditorAuth)
                    {
                        app.SetEditorP12FileName(EditorP12FileName);
                        app.SetEditorServiceAccountEmail(EditorServiceAccountEmail);
                        app.SetEditorP12Password(EditorP12Password);
                    }

                    if (app.Options.DatabaseUrl != null)
                    {
                        app.SetEditorDatabaseUrl(app.Options.DatabaseUrl);
                    }

                    dbref       = FirebaseDatabase.DefaultInstance.RootReference;
                    initialized = true;
                    RefreshScores();
                    readyToInitialize = false;
                    if (FirebaseInitialized != null)
                    {
                        FirebaseInitialized(this, null);
                    }
                }
                return;
            }
            if (refreshScores)
            {
                RefreshScores();
                return;
            }
            if (sendScoreAddedEvent)
            {
                sendScoreAddedEvent = false;
                if (ScoreAdded != null)
                {
                    ScoreAdded(this, userScoreArgs);
                }
                return;
            }
            if (sendUserScoreEvent)
            {
                sendUserScoreEvent = false;
                if (UserScoreUpdated != null)
                {
                    UserScoreUpdated(this, userScoreArgs);
                }
                return;
            }
            if (sendUpdateTopScoresEvent)
            {
                sendUpdateTopScoresEvent = false;
                if (TopScoresUpdated != null)
                {
                    TopScoresUpdated(this, new TopScoreArgs {
                        TopScores = TopScores,
                        StartDate = StartDate,
                        EndDate   = EndDate
                    });
                }
                return;
            }
        }