protected override void OnDestroy() { base.OnDestroy(); foreach (var state in _stateInstances) { state.Value.OnTermination(); } _stateInstances.Clear(); if (CurrentData != null) { CurrentData.OnTermination(); } if (_isAutomate && _isSupportedDataDriver) { AutomaticTask.ClearDataBinding(CurrentData); } if (Main.m_FSM.IsExistFSM(Name)) { Main.m_FSM.UnRegisterFSM(this); } }