Advertisement
Guest User

Untitled

a guest
May 25th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using System;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Register : MonoBehaviour {
  8.  
  9.  
  10. public GameObject username;
  11. public GameObject email;
  12. public GameObject confEmail;
  13. public GameObject password;
  14. public GameObject confPassword;
  15. public GameObject backToLoginButton;
  16. public GameObject createAccountButton;
  17.  
  18.  
  19. private string Username;
  20. private string Email;
  21. private string ConfEmail;
  22. private string Password;
  23. private string ConfPassword;
  24.  
  25.  
  26.  
  27.  
  28. using System;
  29. using System.Text.RegularExpressions;
  30.  
  31. public class Login : MonoBehaviour {
  32.  
  33.  
  34. public GameObject loginButton;
  35. public GameObject exitGameButton;
  36.  
  37. public GameObject username;
  38. public GameObject password;
  39. public GameObject email;
  40.  
  41. //private string NewAccountButton;
  42. private string Username;
  43. private string Password;
  44. private string Email;
  45.  
  46. //Use to contain the url php script
  47. private string LoginUrl = " blab blab blab ";
  48.  
  49.  
  50. // Use this for initialization
  51. void Start () {
  52.  
  53. }
  54.  
  55. public void LoginButton()
  56. {
  57. if (Username != "" && Email != "" && Password != "")
  58. {
  59. StartCoroutine ("LoginAccount");
  60. print ("LoginAccountButton.. works!!!");
  61. }
  62. }
  63.  
  64. // Update is called once per frame
  65. void Update () {
  66. if (Input.GetKeyDown (KeyCode.Tab)) {
  67. if (username.GetComponent<InputField> ().isFocused) {
  68. email.GetComponent<InputField> ().Select ();
  69.  
  70. }
  71. if (email.GetComponent<InputField> ().isFocused) {
  72. password.GetComponent<InputField> ().Select ();
  73.  
  74. }
  75. if (password.GetComponent<InputField> ().isFocused) {
  76. username.GetComponent<InputField> ().Select ();
  77. }
  78.  
  79.  
  80. }
  81.  
  82. Username = username.GetComponent<InputField> ().text;
  83. Email = email.GetComponent<InputField> ().text;
  84. Password = password.GetComponent<InputField> ().text;
  85.  
  86.  
  87. }
  88. IEnumerator LoginAccount()
  89. { //Add our values that will go into the php script
  90. WWWForm Form = new WWWForm ();
  91. //Make sure the "Email" and "Password" are spell the VERY SAME in php script
  92. Form.AddField ("Username", Username);
  93. Form.AddField ("Email", Email);
  94. Form.AddField ("Password", Password);
  95. //Connect to our url, and put in our Form.
  96. WWW LoginAccountWWW = new WWW(LoginUrl, Form);
  97. //Make sure we get the returning information before we continue.
  98. yield return LoginAccountWWW;
  99. if (LoginAccountWWW.error != null) {
  100. Debug.LogError ("Connot connect to Login");
  101. } else
  102. { //translate the WWWText into Debug message
  103. string LogText = LoginAccountWWW.text;
  104. Debug.Log (LogText);
  105.  
  106. string[] LogTextSplit = LogText.Split(':');
  107. //if we have no characters, oad creation, else, load selection.
  108. if (LogTextSplit[0] == "0")
  109. {
  110. if (LogTextSplit[1] == "Success") {
  111. Application.LoadLevel ("CharacterCreation");
  112. } else {
  113. if (LogTextSplit[1] == "Success") {
  114. Application.LoadLevel ("CharacterSelection");
  115. }
  116. }
  117. }
  118. }
  119. }
  120.  
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement