我有最新的FireBaseUnitationSDK-4.3.0
我的统一版本是2017.2.0f3
在我的脚本中,如果我有两个对GetValueAsync().ContinueWith()的调用,第一个调用将被正常执行,第二个调用将停止。如果我以某种方式将这两个调用合并为一个,程序将在第一个调用时停止。
我已经设置了数据库URL和引用。
IEnumerator fetchData()
{
int fetchGameDataStatus = 0;
int fetchPlayerDataStatus = 0;
try
{
reference.Child("PitJumping").GetValueAsync().ContinueWith(fetchTask =>
{
try
{
Debug.Log("Fetching data");
int i = 1;
if(fetchTask.IsCompleted)
{
foreach(var question in fetchTask.Result.Children)
{
int j = 1;
Dictionary<int,string> temp = new Dictionary<int, string>();
foreach(var option in question.Children)
{
temp.Add(j,option.Value.ToString());
j++;
}
gd.dict.Add(i, temp);
i++;
}
Debug.Log("End of task");
fetchGameDataStatus = 1;
}
else
{
Debug.Log(fetchTask.Exception.Message);
fetchGameDataStatus = 2;
}
}
catch(Exception e)
{
Debug.Log(e.Message);
Debug.Log("In fetch task catch!!!");
fetchGameDataStatus = 2;
}
Debug.Log("Reached");
});
}
catch(Exception e)
{
Debug.Log (e.Message);
fetchGameDataStatus = 2;
}
yield return new WaitUntil(()=> fetchGameDataStatus>0);
Debug.Log("fetchGameDataStatus = " + fetchGameDataStatus);
Debug.Log("Going to fetch PlayerData");
try
{
Debug.Log ("Reference set");
reference.Child("users").Child("sampleUserID").Child("PitJumping").GetValueAsync().ContinueWith(fetchTask =>
{
Debug.Log("Task for PlayerData started");
try
{
if (fetchTask.IsCompleted)
{
pd.questionsCompleted = int.Parse(fetchTask.Result.Value.ToString());
fetchPlayerDataStatus = 1;
}
else
{
fetchPlayerDataStatus = 2;
}
}
catch(Exception e)
{
Debug.Log(e.Message);
fetchPlayerDataStatus = 2;
}
});
}
catch(Exception e)
{
Debug.Log (e.Message);
fetchPlayerDataStatus = 2;
}
yield return new WaitUntil(() => (fetchGameDataStatus>0 && fetchPlayerDataStatus>0));
Debug.Log("fetched GD= " + fetchGameDataStatus);
Debug.Log("fetched PD= " + fetchPlayerDataStatus);
}gd是GameData类的一个对象。
pd是PlayerData类的一个对象。
[Serializable]
class GameData
{
public Dictionary<int,Dictionary<int,string>> dict;
public GameData()
{
dict = new Dictionary<int, Dictionary<int, string>>();
}
}
[Serializable]
public class PlayerData
{
public int questionsCompleted;
public PlayerData(int x)
{
questionsCompleted = x;
}
public PlayerData()
{
Debug.Log("Empty constructor");
}
}对不起,没有正确地跟踪MCVE,我不能准确地找出错误的原因。
我意识到堆叠溢出已经有了一个similar question,但是这个答案并没有帮助我解决这个问题。
发布于 2018-09-14 17:06:54
我也有同样的问题,。当“路径”中有数据时,GetValueAsync()按预期执行,但是当路径指向一个空节点时,它会冻结。
原因是因为我在proyect上有DeltaDNA和Firebase插件,而解析器破坏了Firebase的一些重要依赖。
解决方案将删除两者,导入Firebase,禁用解析器的自动解析,并导入DeltaDna,而不使用"dependencies.xml“文件(以及”Plugins/Android“下的文件夹”deltadna-sdk-unity-deltadna“)。
https://stackoverflow.com/questions/48003102
复制相似问题