in database/testapp/Assets/Firebase/Sample/Database/UIHandler.cs [71:99]
protected void StartListener() {
FirebaseDatabase.DefaultInstance
.GetReference("Leaders").OrderByChild("score")
.ValueChanged += (object sender2, ValueChangedEventArgs e2) => {
if (e2.DatabaseError != null) {
Debug.LogError(e2.DatabaseError.Message);
return;
}
Debug.Log("Received values for Leaders.");
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) {
if (childSnapshot.Child("score") == null
|| childSnapshot.Child("score").Value == null) {
Debug.LogError("Bad data in sample.");
break;
} else {
Debug.Log("Leaders entry : " +
childSnapshot.Child("email").Value.ToString() + " - " +
childSnapshot.Child("score").Value.ToString());
leaderBoard.Insert(1, childSnapshot.Child("score").Value.ToString()
+ " " + childSnapshot.Child("email").Value.ToString());
}
}
}
};
}