private void DeleteSelectedItem(bool deleteChildren) { GameObject gameObject = CurrentlySelectedObject; UnityEngine.Object.Destroy(oldObject); oldObject = null; if (!deleteChildren) { ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>(); if (component != null) { this.ObjectBeforeDelete.InvokeSafe(component); } } bool flag = ResetSelected(objectBeingDeleted: true, deleteChildren); if (gameObject != null && !flag) { ManipulatableObject componentInParent = gameObject.GetComponentInParent <ManipulatableObject>(); if (componentInParent != null) { componentInParent.RemoveObject(deleteChildren); } } }
private bool ResetSelected(bool objectBeingDeleted, bool deleteChildren) { bool flag = false; if (CurrentlySelectedObject != null) { ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>(); ObjectManipulator componentInParent = CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>(); if (componentInParent != null) { if (componentInParent.IsAllowed) { Transform parent = CurrentlySelectedObject.transform.parent; CurrentlySelectedObject.transform.SetParent(oldParentOfSelectedObject, worldPositionStays: true); component.SetParent(parent); componentInParent.WasReparented = true; } else if (!restoreOldObject()) { flag = true; } if (!objectBeingDeleted && this.ObjectDeselected != null) { this.ObjectDeselected.InvokeSafe(componentInParent); } if (flag) { component.RemoveObject(deleteChildren); } } } CurrentlySelectedObject = null; return(flag); }
public void ClearCurrentLayout() { if (ObjectManipulationInputController != null) { ObjectManipulationInputController.Reset(); } int childCount = sceneLayoutContainer.childCount; for (int num = childCount - 1; num >= 0; num--) { ManipulatableObject component = sceneLayoutContainer.GetChild(num).GetComponent <ManipulatableObject>(); if (component != null) { component.RemoveObject(deleteChildren: true); } } }
private void removePartneredObject(GameObject obj) { PartneredObject component = obj.GetComponent <PartneredObject>(); if (!(component != null)) { return; } numberTracker.UnregisterNumber(component.Number); if (component.Other != null) { ManipulatableObject component2 = component.Other.gameObject.GetComponent <ManipulatableObject>(); component.Other = null; if (component2 != null) { component2.RemoveObject(deleteChildren: false); } } }
private void onSplittableObjectChildrenSplit(SplittableObject splittableObject) { ManipulatableObject component = splittableObject.GetComponent <ManipulatableObject>(); CollidableObject component2 = splittableObject.GetComponent <CollidableObject>(); int nextAvailable = numberTracker.GetNextAvailable(); GameObject[] splitList = splittableObject.SplitList; foreach (GameObject gameObject in splitList) { CollidableObject collidableObject = gameObject.AddComponent <CollidableObject>(); collidableObject.CollisionRuleSet = component2.CollisionRuleSet; ManipulatableObject manipulatableObject = gameObject.AddComponent <ManipulatableObject>(); gameObject.AddComponent <ManipulatableObjectEffects>(); if (component != null) { manipulatableObject.DefinitionId = component.DefinitionId; } if (this.ObjectAdded != null) { this.ObjectAdded.InvokeSafe(manipulatableObject); } PartneredObject component3 = gameObject.GetComponent <PartneredObject>(); if (component3 != null) { component3.SetOthers(splittableObject.SplitList); component3.SetNumber(nextAvailable); } UpdateLayoutForManipulatableObject(sceneLayoutContainer, manipulatableObject); manipulatableObject.SetParent(sceneLayoutContainer); manipulatableObject.OnRemoved += onObjectRemoved; manipulatableObject.BeforeParentChanged += onBeforeManipulatableObjectReParented; manipulatableObject.AfterParentChanged += onAfterManipulatableObjectReParented; } component.RemoveObject(deleteChildren: false); splittableObject.ChildrenSplit -= onSplittableObjectChildrenSplit; }