- Home /
SceneManager.LoadScene used within promise (or async callback) does nothing
I have a function that signs people up using async / await. Everything in the function works fine, it even completes fine. However, when I try to switch scenes in the callback, it does nothing. It never loads, nor gives an error. Execution of the function just ends there.
public void Sign_Up()
{
FirebaseAuth.DefaultInstance.CreateUserWithEmailAndPasswordAsync(email.text, password.text).ContinueWith(async task =>
{
if (task.IsCanceled)
{
Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
return;
}
if (task.IsFaulted)
{
//Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
Debug.Log("CreateUserWithEmailAndPasswordAsync encountered an error: ");
Debug.Log(task.Exception);
return;
}
// Firebase user has been created.
FirebaseUser newUser = task.Result;
await newUser.SendEmailVerificationAsync();
await newUser.UpdateUserProfileAsync(new UserProfile
{
DisplayName = userName.text,
PhotoUrl = null,
});
await Firebase.Database.FirebaseDatabase.DefaultInstance.RootReference.Child("path").Child(path).Child("path").SetValueAsync(userName.text);
await Firebase.Database.FirebaseDatabase.DefaultInstance.RootReference.Child("path").Child(path.text.ToLower()).SetValueAsync(stuff);
Debug.LogFormat("Firebase user created successfully: {0} ({1})", newUser.DisplayName, newUser.UserId);
SceneManager.LoadScene("map");
Debug.Log("after scene");
Finished = true;
});
Debug.Log("after, after the rest");
}
the code will execute all the way up to loadscene. So far I am forced to use a workaround which is to have a boolean set to true at the end and in update check to see if the bool is set to true then load the level.
Note, the level always loads pretty much instantly, I have let it sit for up to a few min when trying from the callback.
any help would be great.
Your answer
Follow this Question
Related Questions
Loading scene with LoadSceneAsync freezes and progress jumps from 0% to 90% 2 Answers
AsyncOperation activating immediately even with async.allowSceneActivation = false; 0 Answers
Two async operations at the same time not working ? why ? 0 Answers
Can't access AsyncOperation instance to change allowSceneActivation 2 Answers