InputPanel.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace UnityCommon
  6. {
  7. public class InputPanel : MonoBehaviour
  8. {
  9. private bool visible;
  10. public bool Visible
  11. {
  12. get { return visible; }
  13. set
  14. {
  15. gameObject.SetActive(value);
  16. visible = value;
  17. if (visible)
  18. {
  19. SetInfo();
  20. }
  21. }
  22. }
  23. public Text textInfo;
  24. private string mac;
  25. public void SetInfo()
  26. {
  27. mac = SystemInfo.deviceUniqueIdentifier;
  28. GUIUtility.systemCopyBuffer = mac;
  29. textInfo.text = $"该主机未注册,请联系管理员注册。机器码已复制到粘贴板:{mac}";
  30. }
  31. public InputField inputField;
  32. public void OnClickQuit()
  33. {
  34. Application.Quit();
  35. }
  36. public void OnClickReg()
  37. {
  38. var regMd5 = Utility.GetMD5WithString(mac + "swsj202312");
  39. if (regMd5 != inputField.text)
  40. {
  41. textInfo.text = "注册码无效...";
  42. }
  43. else
  44. {
  45. PlayerPrefs.SetString("RegistrationCode", regMd5);
  46. textInfo.text = "注册成功!请重启软件。";
  47. }
  48. }
  49. }
  50. }