private void OnDestroy() { if (_prefabFilter != null) { UndoEx.DestroyObjectImmediate(_prefabFilter); } List <Prefab> prefabs = GetAllPrefabs(); foreach (Prefab prefab in prefabs) { if (prefab != null) { _prefabs.RemoveEntity(prefab); } PrefabWasRemovedFromCategoryMessage.SendToInterestedListeners(this, prefab); } //EnsureActivePrefabPassesPrefabFilter(); foreach (Prefab prefab in prefabs) { if (prefab != null) { UndoEx.DestroyObjectImmediate(prefab); } } }
public void RemoveAndDestroyPrefab(Prefab prefab) { if (ContainsPrefab(prefab)) { _prefabs.RemoveEntity(prefab); EnsureActivePrefabPassesPrefabFilter(); PrefabWasRemovedFromCategoryMessage.SendToInterestedListeners(this, prefab); UndoEx.DestroyObjectImmediate(prefab);; } }
private void RespondToMessage(PrefabWasRemovedFromCategoryMessage message) { var elementWithSamePrefab = GetElementWithPrefab(message.PrefabWhichWasRemoved); if (elementWithSamePrefab != null) { UndoEx.RecordForToolAction(this); UndoEx.RecordForToolAction(elementWithSamePrefab); RemoveAndDestroyElement(elementWithSamePrefab); } }
public void RemoveNullPrefabEntries() { _prefabs.RemoveWithPredicate(item => item == null); List <Prefab> prefabsWithNullUnityPrefabs = _prefabs.GetEntitiesByPredicate(item => item.UnityPrefab == null); if (prefabsWithNullUnityPrefabs.Count != 0) { foreach (Prefab prefab in prefabsWithNullUnityPrefabs) { _prefabs.RemoveEntity(prefab); PrefabWasRemovedFromCategoryMessage.SendToInterestedListeners(this, prefab); Octave3DWorldBuilder.DestroyImmediate(prefab); } EnsureActivePrefabIndexIsNotOutOfRange(); EnsureActivePrefabPassesPrefabFilter(); } }
public void RemoveAndDestroyAllPrefabs() { // Don't know why, but this has to be done in 2 separate passes. Otherwise, the remove operation // is not undone properly in some situations. So first we have to remove the prefabs from the // category and then we have to destroy the prefab instances in a second pass. It drives me insane, // but I just can't figure out why this is necessary :) List <Prefab> prefabs = GetAllPrefabs(); foreach (Prefab prefab in prefabs) { _prefabs.RemoveEntity(prefab); PrefabWasRemovedFromCategoryMessage.SendToInterestedListeners(this, prefab); } EnsureActivePrefabPassesPrefabFilter(); foreach (Prefab prefab in prefabs) { UndoEx.DestroyObjectImmediate(prefab); } }
public static void SendToInterestedListeners(PrefabCategory prefabCategory, Prefab prefabWhichWasRemoved) { var message = new PrefabWasRemovedFromCategoryMessage(prefabCategory, prefabWhichWasRemoved); MessageListenerDatabase.Instance.SendMessageToInterestedListeners(message); }
private void RespondToMessage(PrefabWasRemovedFromCategoryMessage message) { DestroyIfExists(); CreateFromActivePrefabIfNotExists(); }