Hello unity community, I know this question is asked alot and I really have tried to find the answer I’m looking for, but I just don’t know what to search for or where to look.
I just can’t get away from this exception:
NullReferenceException: Object
reference not set to an instance of an
object
LoginScript+c__Iterator2.MoveNext
() (at
Assets/Scripts/LoginScript.cs:91)
All needed variables are public.
All classes have the following applied:
public static ClassName Instance
{
get
{
return _instance;
}
}
private static ClassName _instance;
This is the function that gives me the exception:
IEnumerator login(WWW w)
{
message += "Logging in..";
yield return w;
if (w.error == null)
{
if (w.text == "Success")
{
loggedin = true;
message = "";
status = "Online";
AppManager.Instance.UpdateStatus(); <-- This is where I get the null reference exception
}
else
{
message += w.text;
}
}
else
{
message += "ERROR: " + w.error + "
";
}
}
The UpdateStatus() function looks like this:
public void UpdateStatus()
{
WWWForm updateform = new WWWForm();
updateform.AddField("action", "updatestatus");
updateform.AddField("token", LoginScript.Instance.token);
updateform.AddField("user", LoginScript.Instance.user);
updateform.AddField("status", LoginScript.Instance.status);
updateform.AddField("pos", "");
WWW ww = new WWW(LoginScript.Instance.usermanagerpage, updateform);
StartCoroutine(SendDataToDatabase(ww));
}
Thanks in advance!