- Home /
StartCoroutine not used on a coroutine call
www request ienumerator function doesn't work
hi guys, i have a code that is supposed to do a simple GET on a server, but apparently everything in the getunlockedvalue() doesn't get executed.
Simply put Debug log shows me Debug.Log("pre funkcije") but doesn't show me Debug.Log("I am here dammit!") which makes me think getunlockedvalue() is not working at all.
public Text mytext;
public InputField un, pass;
public Button Continue_button;
string username, password;
string unlocked;
string enkodovan_name;
// Use this for initialization
void Start () {
Continue_button = GetComponent<Button>();
mytext = GetComponentInChildren<Text>();
Continue_button.onClick.AddListener(ProcessText);
}
void ProcessText()
{
mytext.text = "Loging In...";
Continue_button.enabled = false;
username = un.text;
password = pass.text;
enkodovan_name = WWW.EscapeURL(username);
if ((username=="1") && (password == "1"))
Application.LoadLevel("biraj_kulturu");
Debug.Log("pre funkcije");
getunlockedvalue();
}
IEnumerator getunlockedvalue()
{
Debug.Log("I am here dammit!");
WWW otkljucano = new WWW("http://localhost/php_check_password.php" + "?email=" + enkodovan_name + "&password=" + password); //GET data is sent via the URL
while (!otkljucano.isDone && string.IsNullOrEmpty(otkljucano.error))
{
Debug.Log(otkljucano);
yield return unlocked = otkljucano.text;
Debug.Log(unlocked);
if (unlocked == "true") {
PlayerPrefs.SetString("unlocked", "true");
PlayerPrefs.SetString("culture", "none");
PlayerPrefs.SetString("email", username);
Application.LoadLevel("biraj_kulturu"); // Think about adding a screen that says congratulations, you unlocked the game. Bla Bla...
}
Debug.Log(unlocked);
}
if (unlocked == null)
Debug.LogWarning(otkljucano.error);
Continue_button.enabled = true;
}
// Update is called once per frame
void Update () {
}
}
Any help is much appreciated...
To call a coroutine you need to call:
StartCoroutine(CoroutineName())
God, completely overlooked it. Works like a charm. Thanks :)
Follow this Question
Related Questions
Network class vs php for authoritative actions? 1 Answer
How to get different variables from PHP page ? (example included)... 1 Answer
`Recv failure: Connection was reset` In editor? (platform set to Android NOT WebPlayer) 0 Answers
How to grab POST image data from WWWForm on server? 1 Answer
asset bundle works fine on url1 but doesn't on url2? 0 Answers