Login

 avatar
unknown
csharp
2 years ago
1.1 kB
3
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;


public class Login : MonoBehaviour
{
    public string URL;
    

    public void LoginCredentials(string email, string password)
    {
        StartCoroutine(CheckValid(email, password));
    }

    IEnumerator CheckValid(string email, string password)
    {
        using (UnityWebRequest uwr = UnityWebRequest.Get(URL + "?" + email + "&" + password))
        {
            yield return uwr.SendWebRequest();

            if (string.IsNullOrEmpty(uwr.error))
            {
                string[] sub = uwr.downloadHandler.text.Split(':'); //parse string, searches for the result message
                string result = sub[2].Substring(1, sub[2].Length - 3); //
                UiController.Instance.loginResultsTxt.text = result;

            }
        }
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
Editor is loading...
Leave a Comment