namespace IFramework { /// /// OnUpdate OnEnable OnDisable /// public abstract class UpdateModule: Module { private bool _enable; /// /// 开启关闭 Update /// public bool enable { get { return _enable; } set { if (_enable != value) _enable = value; if (_enable) OnEnable(); else OnDisable(); } } /// /// 改变 enable /// /// public void SetActive(bool enable) { this.enable = enable; } /// /// 释放 /// public override void Dispose() { enable = false; base.Dispose(); } /// /// 刷新 /// public void Update() { if (!enable || disposed) return; OnUpdate(); } #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 protected abstract void OnUpdate(); protected virtual void OnEnable() { } protected virtual void OnDisable() { } #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 } }