Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine.UI;
- using System;
- using System.IO;
- using UnityEngine.Networking;
- public class LoginDB : MonoBehaviour {
- public static string user = "";
- private string password = "", id = "";
- public InputField loginInput;
- public InputField passInput;
- public Text text;
- public void toReg()
- {
- Application.LoadLevel("Regist");
- }
- [Serializable]
- public class Data
- {
- public string id;
- public string name;
- public string _class;
- }
- public void Login()
- {
- //message = "";
- user = loginInput.text.ToString ();
- password = passInput.text.ToString ();
- if (user == "" || password == "")
- text.text = "Please enter all the fields \n";
- else
- {
- WWWForm form = new WWWForm();
- form.AddField("email", user);
- form.AddField("password", password);
- WWW www = new WWW("http://uo.cx.ua/api/auth/login", form);
- StartCoroutine(login(www));
- }
- }
- IEnumerator login(WWW www)
- {
- yield return www;
- if (www.error != null)
- {
- Debug.Log ("error " + www.error);
- }
- else
- {
- string json = www.text;
- Data data;
- data = JsonUtility.FromJson<Data> (json);
- Debug.Log (data.id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement