Unity Firebase SetvalueAsync()冻结游戏



如下所示,当我向数据库发送数据时,编辑器卡住了,这是什么原因?为什么代码冻结,即使我异步运行它?

private IEnumerator SetCoinDB(int coinCount)
{
var DBTask = databaseReference.Child("users").Child(firebaseUser.UserId).Child("coins").SetValueAsync(coinCount + User.Instance.coin);
yield return new WaitUntil(predicate: () => DBTask.IsCompleted);
if(DBTask.Exception != null)
{
Debug.LogWarning("Coin update problem");
}
else
{
Debug.Log("Coins updated normally");
}
}

这应该有帮助:https://firebase.blog/posts/2019/07/firebase-and-tasks-how-to-deal-with

使用Unity,你必须小心不要锁定主线程,这在引入协同例程时很容易做到。

最新更新