Unity:Firebase实时数据库-OrderByChild不起作用

时间:2019-04-08 08:50:16

标签: c# firebase unity3d firebase-realtime-database

我在Unity中将Firebase Realtime Database用于具有分数的商店用户。结构:

Users
  2673g4fyuef6tw34
    BestScore: 5
    Name: "Test1"
  d2y3gferfhjy4gff
    BestScore: 0
    Name: "Test2"
  237dyg2fhkalskjr
    BestScore: 10
    Name: "Test3"

我的查询:

var taskResult = await FirebaseDatabase.DefaultInstance
                .GetReference("Users")
                .OrderByChild("BestScore")
                .LimitToLast(20)
                .GetValueAsync()
                .ContinueWith(task => task);

RenderData(taskResult);

我的处理程序:

private void RenderData(Task<DataSnapshot> task)
{
    var snapshot = task.Result;

    foreach (var childSnapshot in snapshot.Children)
    {
        Debug.Log("Score: " + childSnapshot.Child("BestScore").Value);
    }
}

结果:

Score: 5
Score: 0
Score: 10

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

It turned out to be a firebase error in Unity Editor. Everything works on the phone (IOS, Android).