Unity firebase黑屏

loading...


1

我正在开发Android的Unity项目 . 当我构建并运行应用程序后,在Unity启动画面后进入黑屏 .

如果我禁用从Firebase下载网址的脚本,该应用就会完美运行 .

只有具有下载脚本的场景才会出现此问题,所有其他场景运行正常 .

这是用于下载图像和音频的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);
                                }
                            }
                        }
                    }
                }
            }
        }
    });
1回答

  • 0

    我也有这个问题,你需要在第一个场景中初始化firebase SDK和ech服务一次 .

    请确保多次初始化Firebase SDK和服务 .

loading...

评论

暂时没有评论!