//Create new user script private IEnumerator newUser() { SpacePrefs t1 = new SpacePrefs(); PortalPrefs t2 = new PortalPrefs(); string url = "https://evancole.io/newuser.php?"; string post = url + "spacePrefs=" + JsonUtility.ToJson(space) + "&portalPrefs=" + JsonUtility.ToJson(portal) + "&username=" + username; WWW result = new WWW(post); yield return(result); }
//Load data from server private IEnumerator loadServerData() { //Send username to load script on server string url = "https://evancole.io/loadV2.php?"; string post = url + "username="******"username", username); //Post the request and receive the results WWW result2 = new WWW("https://evancole.io/accountStatus.php", form); yield return(result2); accountType = result2.text; PortalAudio.output.playMusic(); //put here to make sure it plays after loading the data if (accountType == "NEW" && username != "admin") //for non admin's, force them to the set password screen if accounts are new { SceneManager.LoadScene("Password"); } else { SceneManager.LoadScene("PortalHome"); //otherwise load portal home } }
//Saves data to the server private IEnumerator saveDataServer(SpacePrefs t1, PortalPrefs t2, History apple, History portal, History space, History ninja, History dino) { string url = "https://evancole.io/saveV2.php"; WWWForm form = new WWWForm(); //Serialize all the objects and add them to a form form.AddField("spacePrefs", JsonUtility.ToJson(t1)); form.AddField("portalPrefs", JsonUtility.ToJson(t2)); form.AddField("portalHist", JsonUtility.ToJson(portal)); form.AddField("appleHist", JsonUtility.ToJson(apple)); form.AddField("spaceHist", JsonUtility.ToJson(space)); form.AddField("ninjaHist", JsonUtility.ToJson(ninja)); form.AddField("dinoHist", JsonUtility.ToJson(dino)); form.AddField("username", username); //submit the form to the URL and have the php deliver the result WWW result = new WWW(url, form); yield return(result); //wait for the result }