Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using System;
- using System.Text.RegularExpressions;
- public class Register : MonoBehaviour {
- public GameObject username;
- public GameObject email;
- public GameObject confEmail;
- public GameObject password;
- public GameObject confPassword;
- public GameObject backToLoginButton;
- public GameObject createAccountButton;
- private string Username;
- private string Email;
- private string ConfEmail;
- private string Password;
- private string ConfPassword;
- using System;
- using System.Text.RegularExpressions;
- public class Login : MonoBehaviour {
- public GameObject loginButton;
- public GameObject exitGameButton;
- public GameObject username;
- public GameObject password;
- public GameObject email;
- //private string NewAccountButton;
- private string Username;
- private string Password;
- private string Email;
- //Use to contain the url php script
- private string LoginUrl = " blab blab blab ";
- // Use this for initialization
- void Start () {
- }
- public void LoginButton()
- {
- if (Username != "" && Email != "" && Password != "")
- {
- StartCoroutine ("LoginAccount");
- print ("LoginAccountButton.. works!!!");
- }
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown (KeyCode.Tab)) {
- if (username.GetComponent<InputField> ().isFocused) {
- email.GetComponent<InputField> ().Select ();
- }
- if (email.GetComponent<InputField> ().isFocused) {
- password.GetComponent<InputField> ().Select ();
- }
- if (password.GetComponent<InputField> ().isFocused) {
- username.GetComponent<InputField> ().Select ();
- }
- }
- Username = username.GetComponent<InputField> ().text;
- Email = email.GetComponent<InputField> ().text;
- Password = password.GetComponent<InputField> ().text;
- }
- IEnumerator LoginAccount()
- { //Add our values that will go into the php script
- WWWForm Form = new WWWForm ();
- //Make sure the "Email" and "Password" are spell the VERY SAME in php script
- Form.AddField ("Username", Username);
- Form.AddField ("Email", Email);
- Form.AddField ("Password", Password);
- //Connect to our url, and put in our Form.
- WWW LoginAccountWWW = new WWW(LoginUrl, Form);
- //Make sure we get the returning information before we continue.
- yield return LoginAccountWWW;
- if (LoginAccountWWW.error != null) {
- Debug.LogError ("Connot connect to Login");
- } else
- { //translate the WWWText into Debug message
- string LogText = LoginAccountWWW.text;
- Debug.Log (LogText);
- string[] LogTextSplit = LogText.Split(':');
- //if we have no characters, oad creation, else, load selection.
- if (LogTextSplit[0] == "0")
- {
- if (LogTextSplit[1] == "Success") {
- Application.LoadLevel ("CharacterCreation");
- } else {
- if (LogTextSplit[1] == "Success") {
- Application.LoadLevel ("CharacterSelection");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement