using FairyGUI;
using UI.Launcher;
using UnityEngine;
namespace GFGGame
{
public class HealthAdviceView
{
private static HealthAdviceView m_Instance = null;
///
/// 单例
///
public static HealthAdviceView Instance
{
get
{
if (m_Instance == null)
{
m_Instance = new HealthAdviceView();
}
return m_Instance;
}
}
private UI_HealthAdviceUI _ui;
///
/// 每1%耗时,单位秒
///
private const float SPEED = 0.01f;
///
/// 界面是否打开状态
///
private bool isOpen = false;
///
/// FairyGUI包名
///
private string _packageName;
#region private
private void Dispose()
{
UIPackage.RemovePackage("UI/" + _packageName);
_ui.Dispose(true);
_ui = null;
}
#endregion
public HealthAdviceView()
{
_packageName = UI_HealthAdviceUI.PACKAGE_NAME;
UIPackage.AddPackage("UI/" + _packageName + "/" + _packageName);
_ui = UI_HealthAdviceUI.Create();
_ui.target.MakeFullScreen();
_ui.target.AddRelation(GRoot.inst, RelationType.Size);
}
///
/// 打开界面
///
public void Open()
{
if (isOpen)
{
return;
}
GRoot.inst.AddChild(_ui.target);
isOpen = true;
}
///
/// 关闭界面
///
///
public void Close(bool toDestroy = false)
{
if (!isOpen)
{
return;
}
isOpen = false;
_ui.target.RemoveFromParent();
if (toDestroy)
{
Dispose();
}
}
}
}