using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MonoBasePanel : MonoBehaviour { bool init; // Start is called before the first frame update protected virtual void Start() { InitPanel(); } //初始化窗口 在start或改变界面时调用 避免出现空引用 protected void InitPanel() { if (init) return; init = true; InitComponent(); } //初始化组件 仅执行一次 子类实现 protected virtual void InitComponent() { } }