//TODO: refactor public override void OnDisable() { if (Toolbox.isQuittingOrChangingScene() || state.released || !state.enabled) { return; } state.enabled = false; state.disabled = true; ProcessingEntities.Default.CheckGroups(id, false); var len = compositionNoTags.Count; int i; for (i = 0; i < len; i++) { Behavior.behaviors[compositionNoTags[i]].RemoveElement(id); } len = compositions != null ? compositions.Count : -1; for (i = 0; i < len; i++) { var composition = compositions[i]; if (composition.changed || !composition.Contain(tags)) { continue; } composition.changed = true; var l = composition.ids.Count; for (var j = 0; j < l; j++) { Behavior.behaviors[composition.ids[j]].RemoveElement(id); } l = composition.delegates.Count; for (var j = 0; j < l; j++) { composition.delegates[j](false); } } if (ProcessingSignals.TryRemoveGlobal(this)) { signals?.Remove(this); } ProcessingUpdate.Default.Remove(this); HandleDisable(); }
protected override void HandleReturnToPool() { ClearTagsAll(); ProcessingEntities.Default.CheckGroups(id, false); var len = compositionNoTags.Count; int i; for (i = 0; i < len; i++) { Behavior.behaviors[compositionNoTags[i]].RemoveElement(id); } len = compositions != null ? compositions.Count : -1; for (i = 0; i < len; i++) { var composition = compositions[i]; composition.changed = false; var l = composition.ids.Count; for (var j = 0; j < l; j++) { Behavior.behaviors[composition.ids[j]].RemoveElement(id); } l = composition.delegates.Count; for (var j = 0; j < l; j++) { composition.delegates[j](false); } } if (ProcessingSignals.TryRemoveGlobal(this)) { signals?.Remove(this); } ProcessingUpdate.Default.Remove(this); // len = compositions != null ? compositions.Count : -1; // // for (i = 0; i < len; i++) // { // compositions[i].changed = false; // } base.HandleReturnToPool(); }
protected void OnDestroy() { if (Toolbox.isQuittingOrChangingScene()) { return; } prevID.Push(id); ProcessingEntities.Default.CheckGroups(id, false); var len = compositionNoTags.Count; int i; for (i = 0; i < len; i++) { Behavior.behaviors[compositionNoTags[i]].RemoveElement(id); } len = compositions != null ? compositions.Count : -1; for (i = 0; i < len; i++) { var composition = compositions[i]; var l = composition.ids.Count; for (var j = 0; j < l; j++) { Behavior.behaviors[composition.ids[j]].RemoveElement(id); } composition.delegates.Clear(); } if (ProcessingSignals.TryRemoveGlobal(this)) { signals?.Remove(this); } ProcessingUpdate.Default.Remove(this); compositionNoTags.Clear(); compositions.Clear(); tags?.Clear(); signals?.Dispose(); signals = null; }
public virtual void OnDisable() { if (Toolbox.isQuittingOrChangingScene() || !state.enabled) { return; } state.enabled = false; if (ProcessingSignals.TryRemoveGlobal(this)) { signals?.Remove(this); } ProcessingUpdate.Default.Remove(this); HandleDisable(); }