UiController
unknown
csharp
2 years ago
2.0 kB
5
Indexable
using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class UiController : MonoBehaviour { public Image fadeImage; public Button loginButton; public bool connectedToServer = true; public TextMeshProUGUI loginResultsTxt; public TextMeshProUGUI loginEmail; public TextMeshProUGUI loginPassword; public string loginURL; private static UiController instance; public static UiController Instance { get { if (!instance) { instance = FindObjectOfType<UiController>(); } return instance; } } public TextMeshProUGUI versionNumberText; public TextMeshProUGUI patchNotes; IEnumerator FadeIn() { float alpha = fadeImage.color.a; for (float i = 0; i < 1; i += Time.deltaTime / 1) { Color newColor = new Color(fadeImage.color.r, fadeImage.color.g, fadeImage.color.b, Mathf.Lerp(alpha, 0f, i)); fadeImage.color = newColor; yield return new WaitForEndOfFrame(); } fadeImage.gameObject.SetActive(false); loginButton.enabled = true; } // Start is called before the first frame update void Start() { loginButton.enabled = false; } public void ConnectedToServer() { StartCoroutine(FadeIn()); } // Update is called once per frame void Update() { if (!connectedToServer) { versionNumberText.text = "Server is not connected..."; patchNotes.text = "Server is not connected..."; } } public void PerformLogin() { Login login = new Login(); login.URL = loginURL; login.LoginCredentials("email=" + loginEmail.text, "password=" + loginPassword.text); } }
Editor is loading...
Leave a Comment