private void OnDisable() { for (int i = 0; i < gizmos.Length; i++) { LevelEditorGLRenderer.Remove(gizmos[i]); } }
private void DeleteObjectInternal(ILevelEditorObject target, bool registerUndo) { if (!pooledObjects.ContainsKey(target.ID)) { pooledObjects.Add(target.ID, new Stack <ILevelEditorObject>()); } objectsWithId.Remove(target.InstanceID); pooledObjects[target.ID].Push(target); activeObjects[target.ID].Remove(target); objectCount[target.ID]--; target.OnPooled(); if (target.MyGameObject.TryGetComponent(out ILevelEditorGizmos gizmos)) { LevelEditorGLRenderer.Remove(gizmos); } if (target.Parent != null) { target.Parent.RemoveChild(target); } if (target.HasChildren()) { //TODO: If deleting children, register delete multiple undo. for (int i = 0; i < target.Children.Count; i++) { DeleteObject(target.Children[i], false); } target.Children.Clear(); } if (registerUndo && Undo != null) { undoComp.AddAction(new DeleteObjectUndoAction(target)); } if (poolObjects) { target.MyGameObject.SetActive(false); } else { Destroy(target.MyGameObject); } OnDeletedObject?.Invoke(this, new LevelEditorObjectEvent(target)); }