IEnumerator sendRegisterRequest(string username, string password, string data) { if (isDatabaseSetup == true) { IEnumerator ee = DC.RegisterUser(username, password, data); while (ee.MoveNext()) { yield return(ee.Current); } WWW returnedd = ee.Current as WWW; if (returnedd.text == "Success") { //Account created successfully blankErrors(); part = 2; //show logged in UI //blank username field input_register_username.text = ""; //password field is blanked at the end of this function, even when error is returned //set logged in username and password to variables loggedIn_Username = username; loggedIn_Password = password; } if (returnedd.text == "usernameInUse") { //Account Not Created due to username being used on another Account part = 1; register_error.text = "Username Unavailable. Try another."; } if (returnedd.text == "ContainsUnsupportedSymbol") { //Account Not Created as one of the parameters contained a - symbol part = 1; register_error.text = "Unsupported Symbol '-'"; } if (returnedd.text == "Error") { //Account Not Created, another error occurred part = 1; login_error.text = "Database Error. Try again later."; } input_register_password.text = ""; input_register_confirmPassword.text = ""; } }
IEnumerator Register(string username, string password, string data) { IEnumerator e = DC.RegisterUser(username, password, data); while (e.MoveNext()) { yield return(e.Current); } WWW returned = e.Current as WWW; if (returned.text == "Success") { PlayerPrefs.SetString("playerName", uname); Application.LoadLevelAsync("Start"); //Account Created Successfully //Do Stuff } if (returned.text == "usernameInUse") { //Account Not Created due to username being used on another account //Do Stuff debug.text = "Username not Available"; proceed.interactable = false; } if (returned.text == "ContainsUnsupportedSymbol") { //Account Not Created as one of the parameters contained a “-“ symbol //this will not be returned in this example as parameters were “a” “b” and “c” //Do Stuff debug.text = "Username not Valid"; proceed.interactable = false; } if (returned.text == "Error") { //Account Not Created, another error occurred //Do Stuff debug.text = "Error"; proceed.interactable = false; } }