我正在为Android开发Unity项目。当我构建并运行该应用时,该应用在Unity启动屏幕之后进入黑屏。
如果我禁用了从Firebase下载URL的脚本,则该应用程序将完美运行。
只有具有下载脚本的场景存在此问题,所有其他场景运行良好。
这是用于下载图像和音频的URL的脚本。
void Start()
{
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Set a flag here indiciating that Firebase is ready to use by your
// application.
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
//URL to Firebase Database
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://fir-web-login-f0757.firebaseio.com/");
// Get the root reference location of the database.
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
//Data snapshot to store query
DataSnapshot _data;
//Query entire database and store in variable;
reference.OrderByKey().LimitToFirst(100).GetValueAsync().ContinueWith(task =>
{
if (task.IsFaulted)
{
//Handle error
}
else if (task.IsCompleted)
{
//Data snapshot of database
_data = task.Result;
//Each course in database
foreach (DataSnapshot d in _data.Children)
{
//Each hole in course
foreach(DataSnapshot e in d.Children)
{
//Each section of the course
foreach(DataSnapshot h in e.Children)
{
//Each URL
foreach(DataSnapshot u in h.Children)
{
//Each folder(image or audio)
foreach (DataSnapshot c in u.Children)
{
//If the key is "image"
if (c.Reference.Parent.Key.Equals("image"))
{
//Write value of DB entry to ArrayList
GameMaster.m_holes.Add(c.Value);
}
//If the key is "audio"
if (c.Reference.Parent.Key.Equals("audio"))
{
//Write value of DB entry to ArrayList
GameMaster.m_audio_files.Add(c.Value);
}
}
}
}
}
}
}
});
答案 0 :(得分:0)
我也有这个问题, 您只需要在第一个场景中一次初始化firebase SDK和ech服务。
确保不要多次初始化Firebase SDK和服务。