1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using UnityEngine;
- using FairyGUI;
- using UI.Launcher;
- 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;
- _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 content)
- {
- GRoot.inst.AddChild(_ui.target);
- _ui.m_txtComp.m_txtContent.text = content;
- _ui.m_txtComp.target.scrollPane.ScrollTop();
- 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();
- }
- }
- }
- }
|