AuthorizationController.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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; // маяк для client
  14. public static bool success = false; // маяк для client
  15. public static bool error = false; // маяк для client
  16. static string textError = "Неправильный логин или пароль";
  17. public GameObject player;
  18. //Client client;
  19. // Start is called before the first frame update
  20. void Start()
  21. {
  22. //client = Client.instance;
  23. var waslogin = PlayerPrefs.GetString("lastlogin");
  24. var waspass = PlayerPrefs.GetString("lastpass");
  25. if (waslogin != null)
  26. Login.text = waslogin;
  27. if (waspass != null)
  28. Password.text = waspass;
  29. DebugHelper.ActivateConsole();
  30. }
  31. // Update is called once per frame
  32. void Update()
  33. {
  34. if (success)
  35. {//SceneManager.LoadScene("Location");
  36. gameObject.SetActive(false);
  37. //client.SendGetUsers((uint)PlayerController.active_company + 1);
  38. //if (ModeController.editor == true && PlayerController.active_location != PlayerController.locations.Count) client.BeaconsRequest((uint)PlayerController.locations[PlayerController.active_location].id);
  39. //if (ModeController.editor == false) client.BeaconsRequest((uint)PlayerController.locations[PlayerController.active_location].id);
  40. }
  41. if(error) Error.SetActive(true);
  42. if (!Client.instance.connected) gameObject.SetActive(true);
  43. }
  44. public void Authorization()
  45. {
  46. login = Login.text;
  47. password = Password.text;
  48. PlayerPrefs.SetString("lastlogin", login);
  49. PlayerPrefs.SetString("lastpass", password);
  50. if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password))
  51. {
  52. Client.instance.SendLogin(login, password);// "8*9Efc2%" "vsheiko"
  53. error = false;
  54. Error.SetActive(false);
  55. }
  56. }
  57. void OnGUI()
  58. {
  59. DebugHelper.DrawConsole();
  60. }
  61. }