Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

iterate though data in firebase unity

public void GetUsers(List<User> users)
{
        FirebaseDatabase.DefaultInstance
  .GetReference("users")
        .GetValueAsync().ContinueWith(task =>
         {
                 if (task.IsFaulted) {
      // Handle the error...
                    Debug.Log("Error was:"+task.Exception.Message);
                    Debug.LogError("Error was:"+task.Result.Children);
            }
            else if (task.IsCompleted) {
            DataSnapshot snapshot = task.Result;
            // Do something with snapshot...
                        foreach(DataSnapshot s in snapshot.Children){
                        IDictionary dictUsers = (IDictionary)s.Value;   
                        Debug.Log(dictUsers["displayName"]);                    
                    }   
                    // After this foreach loop in snapshot.Children, nothing executes
                    UIManager.instance.ShowOtherUsers();
            }
  });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #iterate #data #firebase #unity
ADD COMMENT
Topic
Name
1+8 =