Advertisement
vitelize

Unity Login WWW Classe

Jul 17th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. // From http://blogs.floriancavallo.fr/post/2012/07/17/Unity-Creer-une-interface-de-Login.aspx
  2.  
  3. private void makeLogin(string username,string password)
  4.     {
  5.  
  6.        WWWForm form = new WWWForm();
  7.  
  8.         form.AddField("login", username);
  9.         form.AddField("password", password);
  10.  
  11.         //WWW www = new WWW("http://monserveur.fr/connexion.php", form);
  12.         WWW www = new WWW("http://monserveur.fr/connexion.php?login="+username+"&password="+password);
  13.        
  14.        
  15.         //Ici on lance le login en Asynchrone
  16.         StartCoroutine(WaitForRequest(www));      
  17.     }
  18.  
  19. private IEnumerator WaitForRequest(WWW www)
  20.     {        
  21.         yield return www;
  22.    
  23.         if (www.error == null)
  24.         {
  25.             if(www.text == "connexionOk"){
  26.                 Application.LoadLevel(1);
  27.             }
  28.         }
  29.         else
  30.         {
  31.             Debug.Log("WWW Error: " + www.error);
  32.         }
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement