AuthorizationController.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.SceneManagement;
  4. using UnityEngine.UI;
  5. public class AuthorizationController : MonoBehaviour
  6. {
  7. public static string login;
  8. public static string password;
  9. public InputField Login;
  10. public InputField Password;
  11. public GameObject Error;
  12. public GameObject loading;
  13. public static bool send = false;
  14. public static bool success = false;
  15. public static bool error = false;
  16. static string textError = "Неправильный логин или пароль";
  17. Client client;
  18. // Start is called before the first frame update
  19. void Start()
  20. {
  21. client = Client.instance;
  22. var waslogin = PlayerPrefs.GetString("lastlogin");
  23. var waspass = PlayerPrefs.GetString("lastpass");
  24. if (waslogin != null)
  25. Login.text = waslogin;
  26. if (waspass != null)
  27. Password.text = waspass;
  28. DebugHelper.ActivateConsole();
  29. }
  30. // Update is called once per frame
  31. void Update()
  32. {
  33. if (success)
  34. {//SceneManager.LoadScene("Location");
  35. transform.gameObject.SetActive(false);
  36. client.SendGetUsers((uint)PlayerController.active_company + 1);
  37. client.BeaconsRequest((uint)PlayerController.locations[PlayerController.active_location].id);
  38. }
  39. if(error) Error.SetActive(true);
  40. }
  41. public void Authorization()
  42. {
  43. login = Login.text;
  44. password = Password.text;
  45. PlayerPrefs.SetString("lastlogin", login);
  46. PlayerPrefs.SetString("lastpass", password);
  47. if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password))
  48. {
  49. send = true;
  50. error = false;
  51. Error.SetActive(false);
  52. }
  53. }
  54. void OnGUI()
  55. {
  56. DebugHelper.DrawConsole();
  57. }
  58. }