Files

52 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
namespace XericUI.VisualForm
{
/// <summary>
/// 虚拟窗体基类,提供基础的窗体标记功能
/// </summary>
[AddComponentMenu("Xeric UI Vessel/AnchorWindow/XvFormBase")]
public class XvFormBase : MonoBehaviour
{
[SerializeField]
private string m_FormID;
/// <summary>
/// 窗体唯一标识
/// </summary>
public string FormID
{
get => m_FormID;
set => m_FormID = value;
}
/// <summary>
/// 窗体是否处于活动状态
/// </summary>
public bool IsFormActive => gameObject.activeInHierarchy && enabled;
protected virtual void Awake()
{
TryGenerateFormID();
}
/// <summary>
/// 尝试自动生成FormID如果当前为空
/// </summary>
private void TryGenerateFormID()
{
if (string.IsNullOrEmpty(m_FormID))
{
m_FormID = ((uint)GetInstanceID()).ToString();
}
}
#if UNITY_EDITOR
protected virtual void OnValidate()
{
TryGenerateFormID();
}
#endif
}
}