StartCoroutine in a static member
Question
I have two scripts, one that grabs information from the other and sends information
Example :
Usage
var savedWeapons = PlayerSave.GetWeapons();
Now PlayerSave does this
public static string GetWeapons()
{
StartCoroutine (GetData ("weapon", "testname"));
return returner;
}
IEnumerator GetData(string type, string accountName)
{
var form = new WWWForm ();
form.AddField ("hash", hash);
form.AddField ("name", accountName);
form.AddField ("type", type);
WWW w = new WWW (URL, form);
yield return w;
if (w.error != null) {
//Show Error
Debug.Log(w.error);
returner = w.error;
w.Dispose();
}
else {
Debug.Log(w.text);
returner = w.text;
w.Dispose();
}
}
So basically it gets it from the database. However I get this error
Assets/Scripts/Scripts/PlayerSave.cs(53,19): error CS0120: An object reference is required to access non-static member 'PlayerSave.GetData(string, string)'
But if i take away the static member away it gives me an error in the script calling for the weapon.
Any help?
BTW I did look at this - https://answers.unity.com/questions/1207534/startcoroutine-in-a-public-static-void.html
Didn't work for me.
Your answer
Follow this Question
Related Questions
StartCoroutine & WaitForSeconds Error 1 Answer
UI image component problems with Character Creation.... 0 Answers
why the startcoroutine (spawnbigtree()); doesn't work and float don't work 0 Answers
NullRefException at Index 0 in list 0 Answers
How do I save Entered Name and show it for the rest of the game? 0 Answers