FullScreenTextView.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.Launcher;
  4. using System;
  5. namespace GFGGame
  6. {
  7. public class FullScreenTextView
  8. {
  9. private static FullScreenTextView m_Instance = null;
  10. /// <summary>
  11. /// µ¥Àý
  12. /// </summary>
  13. public static FullScreenTextView Instance
  14. {
  15. get
  16. {
  17. if (m_Instance == null)
  18. {
  19. m_Instance = new FullScreenTextView();
  20. }
  21. return m_Instance;
  22. }
  23. }
  24. private UI_FullScreenTextUI _ui;
  25. /// <summary>
  26. /// FairyGUI°üÃû
  27. /// </summary>
  28. private string _packageName;
  29. public void Dispose()
  30. {
  31. if (_ui != null)
  32. {
  33. _ui.Dispose();
  34. _ui = null;
  35. }
  36. }
  37. public FullScreenTextView()
  38. {
  39. _packageName = UI_FullScreenTextUI.PACKAGE_NAME;
  40. _ui = UI_FullScreenTextUI.Create();
  41. UIPackage.AddPackage("UI/" + _packageName + "/" + _packageName);
  42. _ui = UI_FullScreenTextUI.Create();
  43. _ui.target.MakeFullScreen();
  44. _ui.target.AddRelation(GRoot.inst, RelationType.Size);
  45. _ui.m_btnBack.onClick.Add(this.Hide);
  46. }
  47. public void Show(string eventName)
  48. {
  49. GRoot.inst.AddChild(_ui.target);
  50. _ui.m_txtComp.m_txtContent.text = "¼ÓÔØÖÐ...";
  51. _ui.m_txtComp.target.scrollPane.ScrollTop();
  52. LoadText(eventName);
  53. Timers.inst.AddUpdate(Update);
  54. }
  55. public void Hide()
  56. {
  57. Timers.inst.Remove(Update);
  58. _ui.target.RemoveFromParent();
  59. }
  60. private void Update(object param)
  61. {
  62. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
  63. {
  64. this.Hide();
  65. }
  66. }
  67. private void LoadText(string eventName)
  68. {
  69. string fileName = null;
  70. switch (eventName)
  71. {
  72. case "event:a":
  73. fileName = "serviceProtocal";
  74. break;
  75. case "event:b":
  76. fileName = "privacyPolicy";
  77. break;
  78. case "event:c":
  79. fileName = "privacyPolicyChildren";
  80. break;
  81. default:
  82. return;
  83. }
  84. string url = LauncherConfig.CDN_ROOT + $"privacy/{fileName}.txt?v={LauncherConfig.privacy_v}";
  85. HttpTool.Instance.Get(url, (string content) =>
  86. {
  87. _ui.m_txtComp.m_txtContent.text = content;
  88. });
  89. }
  90. }
  91. }