使用 Firebase 在 Unity 中添加用户时出错

Error adding user in Unity using Firebase

这是我将新注册用户添加到 Firebase 数据库的代码:

    TransactionResult AddUserToDatabaseTransaction(MutableData mutableData) {


    if (mutableData != null)
    {
    List<object> users = mutableData.Value as List<object>;

    if (users == null) 
      {   users = new List<object>();
                                          }

    users = new List<object>();
    // Now we add the new score as a new entry that contains the email address and score.
    Dictionary<string, object> newUserRegistration = new Dictionary<string, object>();

    newUserRegistration["Dateofbirth"] = "22/03/1980";
    newUserRegistration["Email"] = auth.CurrentUser.Email;
    newUserRegistration["Full Name"] = "cool";
    newUserRegistration["LastLoggedIn"] = "27/06/2017";
    newUserRegistration["RegistrationDate"] = "26/04/2017";



    users.Add(newUserRegistration);

    // You must set the Value to indicate data at that location has changed.
    mutableData.Value = users;
    return TransactionResult.Success(mutableData);
}
else return TransactionResult.Abort();
  }

 public void AddUserToDatabase() {
    DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("users");
    DatabaseReference usersaddnow = reference.Child(auth.CurrentUser.UserId);

    usersaddnow.RunTransaction(AddUserToDatabaseTransaction)
      .ContinueWith(task => {
      if (task.Exception != null) {
         information.text +=task.Exception.ToString();
      } else if (task.IsCompleted) {
        information.text += " Transaction complete.";
      }
    }
    );
  }

这是数据库的快照:

所以,我正在尝试将用户添加到数据库中。 正如您从图片中看到的那样,我成功地添加了它们,但是它在用户详细信息之前添加了一个零子项。你能告诉我为什么会这样吗? 几个小时以来,我一直试图摆脱它,但找不到解决方案。

问题是因为arraylist 它通过自己的索引设置数据,即 0,1 等

所以看起来统一它默认使用这些索引 我可以访问测试和内部元素 以这种方式管理和访问数据更容易