Guest User

Untitled

a guest
Jun 10th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. public string userLoginFile = "http://localhost/UserLogin.php?";
  2.  
  3.         string username = "";
  4.         string password = "";
  5.         string email;
  6.  
  7.     public void LoginGUI()
  8.         {
  9.            GUI.skin = this.guiSkin;
  10.  
  11.            username = GUI.TextField (new Rect(Screen.width / 2 - 110, Screen.height / 2 - 20, 220, 30), username, GUI.skin.GetStyle("textfield"));
  12.            password = GUI.PasswordField (new Rect(Screen.width / 2 - 110, Screen.height / 2 + 15, 220, 30), password, "*"[0], GUI.skin.GetStyle("textfield"));
  13.            if(GUI.Button (new Rect(Screen.width / 2 - 110, Screen.height / 2 + 50, 220, 30), "Login", GUI.skin.GetStyle("button")))
  14.            {
  15.              StartCoroutine(LoginUser(username, password));
  16.            }
  17.  
  18.            GUILayout.Label(email);
  19.         }
  20.  
  21.         IEnumerator LoginUser(string user, string pass)
  22.         {
  23.            WWW login = new WWW(userLoginFile + "username=" + user + "&password=" + pass);
  24.            yield return login;
  25.  
  26.            if(login.error == null)
  27.            {
  28.              string[] credentials = login.text.Split('/');
  29.              foreach (string str in credentials)
  30.              {
  31.               string[] creds = str.Split('=');
  32.  
  33.               for(int i=0; i < creds.Length; i++)
  34.               {
  35.                   if(creds[i] == "email")
  36.                   {
  37.                      email = creds[i + 1];
  38.                      this.currentGUIMethod = MainMenuGUI;
  39.                   }
  40.               }
  41.              }
  42.            }
  43.         }
Advertisement
Add Comment
Please, Sign In to add comment