unity3d Unity Firebase设定值异步()冻结游戏

qhhrdooz  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(142)

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

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");
    }
}
qjp7pelc

qjp7pelc1#

这应有助于:https://firebase.blog/posts/2019/07/firebase-and-tasks-how-to-deal-with
使用Unity时,您必须小心不要锁定主线程,这在引入协同例程时很容易做到。

相关问题