I am attempting to polish up a login and register script for a unity app. I've created a callback action delegate and I attempt to pass parameters in via a lambda expression. however, when it calls another function in the second script, i get a null reference exception.
this is how i pass it in. note that registerUser is the second script
if (checkPassword(password) && password == confirm)
{
registerUser.RegisterScene(email, password, user, (isSuccess, errorMsg) =>
{
if (isSuccess)
{
Debug.Log(errorMsg);
StartCoroutine(errorMessage(errorMsg, Color.green, 3f));
}
if (!isSuccess)
{
Debug.Log(errorMsg);
StartCoroutine(errorMessage(errorMsg, Color.red, 3f));
}
});
}
and this is where i get the null reference exception.
public static void RegisterScene(string email, string password, string user, Action<bool, string> callback)
{
_instance.registerAsync(email, password, user, callback);
}
i am unsure as to why i am getting this error so if anyone can clear this up for me that whould be great thanks!
EDIT: here is how i declare my singleton. i didnt make it thread safe or put anything fancy in it. i just want it to work
public Profile()
{
}
void start()
{
Debug.Log(_instance);
if (_instance == null)
{
_instance = new Profile();
Debug.Log(_instance);
}
}