【发布时间】:2020-06-26 23:17:34
【问题描述】:
我正在尝试创建一个类来管理我的 Cloud Firestore 请求(就像任何 SQLiteHelper 类一样)。但是,firebase 使用异步调用,我无法将值返回给其他脚本。 这里是一个例子(布尔返回):
public bool CheckIfIsFullyRegistered(string idUtente)
{
DocumentReference docRef = db.Collection("Utenti").Document(idUtente);
docRef.GetSnapshotAsync().ContinueWithOnMainThread(task =>
{
DocumentSnapshot snapshot = task.Result;
if (snapshot.Exists)
{
Debug.Log(String.Format("Document {0} exist!", snapshot.Id));
return true; //Error here
}
else
{
Debug.Log(String.Format("Document {0} does not exist!", snapshot.Id));
}
});
}
【问题讨论】:
标签: c# firebase unity3d asynchronous