【发布时间】:2023-02-13 03:37:08
【问题描述】:
Firebase 只能在 unity editor 上工作,当我们实际将它构建到 android 时,它会卡在等待使用电子邮件和密码功能登录。虽然,它似乎在某种程度上起作用,因为我们可以在 firebase 网站上看到流量。因此,我们尝试使用更简单的代码来代替,这是其他人的建议,但它仍然没有通过异步代码,我是否缺少任何解决方案,也许播放器设置中的某些内容阻止它工作。
//Heres the current code, the texts are just flags, and it gets to "sigma" and never loads next scene:
using Firebase.Extensions;
using Firebase;
using Firebase.Auth;
using Firebase.Database;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Android;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
public class Permissions : MonoBehaviour
{
[SerializeField] TMP_Text t;
string[] temp = { Permission.ExternalStorageRead, Permission.ExternalStorageWrite };
// Start is called before the first frame update
void Start()
{
//Permission.RequestUserPermissions(temp);
t.text = "ligma";
CheckIfReady();
}
public void CheckIfReady()
{
t.text = "sigma";
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
Firebase.DependencyStatus dependencyStatus = task.Result;
t.text = "figma";
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
SceneManager.LoadScene("Auth");
// Debug.Log("Firebase is ready for use.");
}
else
{
t.text = "else";
}
});
}
}
我们尝试使用前面提到的代码,因为我们认为这是一个依赖问题,但即使这样也失败了,所以现在我们真的不知道该怎么做。也许在播放器设置中。我还尝试向 chatGPT 询问一些答案,它建议使用 .NET 4.x 的运行时脚本,但我没能找到。我只找到后端脚本,只有.NET 2.1 和.NET 框架。我真的不知道这是否是一个问题,但我不确定。
再次只是遇到错误,但在实际构建游戏时,编辑器运行良好。
【问题讨论】:
标签: c# android firebase unity3d