跳转至

HelperMonitorPanel抽象类

1. 首先是一些枚举

  • 内容状态
  • 可视化元素类型
        public abstract class HelperMonitorPanel
        {
            #region InternalClass
            protected enum ContentDataState
            {
                Useless = -1, // 表示待删除
                Clean = 0,   //表示无需改动
                Dirty = 1, // 表示有数据变动
                New = 2,   // 表示新创建的
            }
    
            public enum VisualElementType
            {
                TextField = 0, // TextField
                Button = 1, // 按钮
                DropDownList=2,//下拉列表
            }
    
    #endregion
    

2.引用类声明

        public List<float> fieldWidthList;
        protected HelperMonitorContext Context => parent.context;

        protected HelperMonitor_UIElement parent;

        protected HelperTagContent tagContent;

        protected bool m_enter;

        protected VisualElement mainPanel ;
        protected ActorContent m_selectedActor => parent.SelectedActor;
        public  Dictionary<uint, ActorContentDataRow> ActorContentDataRow => parent.ActorContentDataRow;

3.生命周期函数

  • 创建与初始化OnCreate
  • 摧毁OnDestroy
  • 进入OnEnter
  • 退出OnExit
  • GUI显示OnGUI
     public virtual void OnCreate(HelperMonitor_UIElement _parent, VisualElement _mainPanel, HelperTagContent _content)
     {
         tagContent = _content;
         parent = _parent;
         mainPanel = _mainPanel;
    
         LoadUXML();
             //Logger.LogError("onCreate " + tagContent.helperName);
         m_enter = false;
         fieldWidthList=new List<float>();
     }
    
    public virtual void OnDestroy()
    {
        //Logger.LogError("onDestry" + tagContent.helperName);
    
        m_enter = false;
    }
    

4. 功能函数

  • OnSwitchActor:当选择了角色
  • LoadUXML():加载UXML信息
  • SaveTagWidth
  • SetElementWidth