AuthorizationController.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. if (ModeController.editor == true && PlayerController.active_location != PlayerController.locations.Count) client.BeaconsRequest((uint)PlayerController.locations[PlayerController.active_location].id);
  38. if (ModeController.editor == false) client.BeaconsRequest((uint)PlayerController.locations[PlayerController.active_location].id);
  39. }
  40. if(error) Error.SetActive(true);
  41. }
  42. public void Authorization()
  43. {
  44. login = Login.text;
  45. password = Password.text;
  46. PlayerPrefs.SetString("lastlogin", login);
  47. PlayerPrefs.SetString("lastpass", password);
  48. if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password))
  49. {
  50. send = true;
  51. error = false;
  52. Error.SetActive(false);
  53. }
  54. }
  55. void OnGUI()
  56. {
  57. DebugHelper.DrawConsole();
  58. }
  59. }