using UnityEngine; using FairyGUI; using UI.Launcher; using System; namespace GFGGame { public class FullScreenTextView { private static FullScreenTextView m_Instance = null; /// /// 单例 /// public static FullScreenTextView Instance { get { if (m_Instance == null) { m_Instance = new FullScreenTextView(); } return m_Instance; } } private UI_FullScreenTextUI _ui; /// /// FairyGUI包名 /// private string _packageName; public void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } } public FullScreenTextView() { _packageName = UI_FullScreenTextUI.PACKAGE_NAME; _ui = UI_FullScreenTextUI.Create(); UIPackage.AddPackage("UI/" + _packageName + "/" + _packageName); _ui = UI_FullScreenTextUI.Create(); _ui.target.MakeFullScreen(); _ui.target.AddRelation(GRoot.inst, RelationType.Size); _ui.m_btnBack.onClick.Add(this.Hide); } public void Show(string eventName) { GRoot.inst.AddChild(_ui.target); _ui.m_txtComp.m_txtContent.text = "加载中..."; _ui.m_txtComp.target.scrollPane.ScrollTop(); LoadText(eventName); Timers.inst.AddUpdate(Update); } public void Hide() { Timers.inst.Remove(Update); _ui.target.RemoveFromParent(); } private void Update(object param) { if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home)) { this.Hide(); } } private void LoadText(string eventName) { string fileName = null; switch (eventName) { case "event:a": fileName = "serviceProtocal"; break; case "event:b": fileName = "privacyPolicy"; break; case "event:c": fileName = "privacyPolicyChildren"; break; default: return; } string url = LauncherConfig.CDN_ROOT + $"privacy/{fileName}.txt?v={LauncherConfig.privacy_v}"; HttpTool.Instance.Get(url, (string content) => { _ui.m_txtComp.m_txtContent.text = content; }); } } }