I am a Unity beginner and I am getting stuck on a really simple thing.
I want to login using the Parse SDK and if the login returns true I want to load the menu scene.
I have a login screen with a Login button and onclick I have the following function
public void LoginParse ()
{
GameObject usernamebox = GameObject.Find("UsernameBox");
InputField usernamefield = usernamebox.GetComponent<InputField>();
GameObject passwordbox = GameObject.Find("PasswordBox");
InputField passwordfield = passwordbox.GetComponent<InputField>();
ParseUser.LogOut();
AuthenticateParse (usernamefield.text, passwordfield.text);
//if there is whatever piece of code here, this makes Unity freeze
// I would like to check if the task of Authentication is finished and if so check the current user.
//If true then I would like to run Application.LoadLevel ("scenemenu");
}
public void AuthenticateParse(string usern,string pass)
{
ParseUser user = null;
ParseUser.LogInAsync(usern, pass).ContinueWith (t =>
{
if (t.IsFaulted || t.IsCanceled) {
//exceptions
} else {
user = t.Result;
}
});
}
Whenever I add code after the LoginAsync call unity gets frozen and I need to end it with the task manager. What am I missing? Thank you!