SHOW:
|
|
- or go back to the newest paste.
1 | using UnityEngine; | |
2 | using System.Collections; | |
3 | ||
4 | public class Menu : MonoBehaviour | |
5 | { | |
6 | ||
7 | string loginURL = "localhost"; | |
8 | ||
9 | string username = ""; | |
10 | string password = ""; | |
11 | string label = ""; | |
12 | ||
13 | void OnGUI() | |
14 | { | |
15 | GUI.Window(0, new Rect(Screen.width / 6, Screen.height / 4, 220, 260), LoginWindow, "Login"); | |
16 | } | |
17 | ||
18 | ||
19 | ||
20 | void LoginWindow(int OnGUI) | |
21 | { | |
22 | GUI.Label(new Rect(10,30,200,30), "Username"); | |
23 | username = GUI.TextField(new Rect(10,60,200,30), username); | |
24 | GUI.Label(new Rect(10,100,200,30), "Password"); | |
25 | password = GUI.TextField(new Rect(10,130,200,30), password, '*'); | |
26 | if (GUI.Button(new Rect(10,170,200,30), "Login")) | |
27 | { | |
28 | StartCoroutine(HandleLogin(username, password)); | |
29 | Debug.Log("connect button pressed"); | |
30 | } | |
31 | GUI.Label (new Rect(10,200,200,60), label); | |
32 | } | |
33 | ||
34 | ||
35 | ||
36 | IEnumerator HandleLogin(string username, string password) | |
37 | { | |
38 | label = "Checking username and password."; | |
39 | - | string loginURL = this.loginURL + "?username=" + username + "&password=" + password; |
39 | + | string loginURL = this.loginURL + "?UserAccountName=" + username + "&UserAccountPassword=" + password; |
40 | WWW loginReader = new WWW(loginURL); | |
41 | yield return loginReader; | |
42 | Debug.Log (username); | |
43 | ||
44 | if(loginReader.error != null) | |
45 | { | |
46 | Debug.Log ("error1"); | |
47 | label = "Error connecting to database server."; | |
48 | } | |
49 | else | |
50 | { | |
51 | - | if (loginReader.text == "success") |
51 | + | if (loginReader.text == "Success") |
52 | { | |
53 | label = "Successfully logged in."; | |
54 | Debug.Log ("yay fucking finally"); | |
55 | } | |
56 | else | |
57 | { | |
58 | label = "Invalid username or password."; | |
59 | Debug.Log ("Connected, but wrong user/password"); | |
60 | } | |
61 | } | |
62 | } | |
63 | } |