123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using UnityEngine;
- using FairyGUI;
- using UI.Launcher;
- using System;
- namespace GFGGame
- {
- public class FullScreenTextView
- {
- private static FullScreenTextView m_Instance = null;
- /// <summary>
- /// 单例
- /// </summary>
- public static FullScreenTextView Instance
- {
- get
- {
- if (m_Instance == null)
- {
- m_Instance = new FullScreenTextView();
- }
- return m_Instance;
- }
- }
- private UI_FullScreenTextUI _ui;
- /// <summary>
- /// FairyGUI包名
- /// </summary>
- private string _packageName;
- public void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- }
- public FullScreenTextView()
- {
- _packageName = UI_FullScreenTextUI.PACKAGE_NAME;
- 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 = string.Format(LauncherConfig.privacy_v, fileName);
- HttpTool.Instance.Get(url, (string content) =>
- {
- _ui.m_txtComp.m_txtContent.text = content;
- });
- }
- }
- }
|