Нужна помощь, нужно открыть следующую сену после возвращения данных из Firebase. Но появляется ошибка, что я не в основном потоке, может кто то сталкивался.
public class StartScript : MonoBehaviour {
void Start () {
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("my_url");
FirebaseDatabase.DefaultInstance
.GetReference("/")
.GetValueAsync().ContinueWith(task => {
if (task.IsFaulted)
{
// Handle the error...
}
else if (task.IsCompleted)
{
DataSnapshot snapshot = task.Result;
// Do something with snapshot...
if (snapshot.Value.Equals("none")) {
SceneManager.LoadScene(1);
}
}
});
}
void Update () {
}
}
Ошибка:
**LoadSceneAsyncNameIndexInternal can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. UnityEngine.SceneManagement.SceneManager:LoadScene(Int32) StartScript:m__0(Task`1) (at Assets/Scripts/StartScript.cs:31) System.Threading._ThreadPoolWaitCallback:PerformWaitCallback() **