gpt4 book ai didi

firebase - 从 Unity 中的 Firestore 获取集合?

转载 作者:行者123 更新时间:2023-12-05 02:08:30 27 4
gpt4 key购买 nike

我正在尝试通过关注 this link 在 Unity 中获取一个 firestore 集合,但它给了我一个错误:

'Task' does not contain a definition for 'Documents' and no accessible extension method 'Documents' accepting a first argument of type 'Task'.

我的代码:

CollectionReference allCitiesQuery = db.Collection("MyList");
Task<QuerySnapshot> allCitiesQuerySnapshot = allCitiesQuery.GetSnapshotAsync();

foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.Documents)
{
Dictionary<string, object> city = documentSnapshot.ToDictionary();
foreach (KeyValuePair<string, object> pair in city)
{
Debug.Log(pair.Key + " " + pair.Value);
//Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
}
}
}

我已经阅读了文档,但很少关注 Unity,因为几天前它才刚刚实现。有人可以帮我吗?

最佳答案

尝试改变

CollectionReference allCitiesQuery = db.Collection("MyList");
Task<QuerySnapshot> allCitiesQuerySnapshot = allCitiesQuery.GetSnapshotAsync();

进入

Query allCitiesQuery = db.Collection("MyList");
QuerySnapshot allCitiesQuerySnapshot = await allCitiesQuery.GetSnapshotAsync();

并确保您拥有以下所有内容:

using Firebase;
using Firebase.Firestore;
using Firebase.Extensions;

关于firebase - 从 Unity 中的 Firestore 获取集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60832414/

27 4 0
文章推荐: react-native - 如何在 React Native Top Navigation 中正确更改 indicatorStyle 的宽度?
文章推荐: javascript - 警告 : Expected server HTML to contain a matching in
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com