using UnityEngine;
using System.Collections;
public class loginscript : MonoBehaviour {
public string pass = "Password";
public string user = "Username";
public string url = "YOUR URL";
void OnGUI (){
user = GUI.TextField( new Rect(Screen.width/2-155, Screen.height/2-50, 310, 30), user, 25);
pass = GUI.PasswordField( new Rect(Screen.width/2-155, Screen.height/2, 310, 30), pass, "•"[0], 25);
if(GUI.Button( new Rect(Screen.width/2-155, Screen.height/2+50, 310, 30), "Enter to the game")){
StartCoroutine(Login(user, pass));
}
}
IEnumerator Login(string username, string password){
WWWForm form= new WWWForm();
form.AddField("myusername", username);
form.AddField("mypassword", password);
WWW login= new WWW(url, form);
yield return login;
string a = login.text;
print(a);
if(a=="Ok"){
Application.LoadLevel(1);
}else{
Debug.Log("Not Logged");
}
}
}