private void onObjectSelected(ManipulatableObject obj) { if (obj == null) { return; } for (int i = 0; i < sceneModifiers.Length; i++) { if (!sceneModifiers[i].CanObjectBeSelected(obj)) { return; } } ObjectManipulator objectManipulator = obj.gameObject.AddComponentIfMissing <ObjectManipulator>(); objectManipulationManager.WatchObject(objectManipulator); obj.GetComponent <CollidableObject>().EnableTriggers(); obj.GetComponent <ManipulatableObjectEffects>().SetObjectManipulator(objectManipulator); Rigidbody rigidbody = obj.gameObject.AddComponentIfMissing <Rigidbody>(); rigidbody.isKinematic = true; rigidbody.useGravity = false; for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].AfterObjectSelected(obj, isNewObject); } isNewObject = false; selectedObjectStartingId = GetRelativeGameObjectPath(obj.gameObject); ManipulatableObject[] componentsInChildren = obj.GetComponentsInChildren <ManipulatableObject>(); foreach (ManipulatableObject manipulatableObject in componentsInChildren) { manipulatableObject.PathId = GetRelativeGameObjectPath(manipulatableObject.gameObject); } }
private void onConfirmSquashedObjectBeforeDragComplete(ObjectManipulator selected, Action <bool> callback) { if (selected == null) { return; } HashSet <ManipulatableObject> squashed = new HashSet <ManipulatableObject>(); foreach (Collider currentCollider in selected.CurrentColliders) { ManipulatableObject componentInParent = currentCollider.GetComponentInParent <ManipulatableObject>(); if (componentInParent != null && componentInParent.IsSquashed) { squashed.Add(componentInParent); ManipulatableObject[] componentsInChildren = componentInParent.GetComponentsInChildren <ManipulatableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { squashed.Add(componentsInChildren[i]); } } } Action <int, Action <bool> > confirmObjectRemoval = Service.Get <ObjectManipulationService>().ConfirmObjectRemoval; if (squashed.Count > 0 && confirmObjectRemoval != null) { confirmObjectRemoval(squashed.Count, delegate(bool delete) { if (delete) { foreach (ManipulatableObject item in squashed) { if (item != null) { item.RemoveObject(deleteChildren: false); } } } objectManipulationInputController.SkipOneFrame = true; if (callback != null) { callback(delete); } }); return; } foreach (ManipulatableObject item2 in squashed) { if (item2 != null) { item2.RemoveObject(deleteChildren: false); } } if (callback != null) { callback(obj: true); } }
private void onObjectBeforeDelete(ManipulatableObject mo) { ManipulatableObject[] componentsInChildren = mo.GetComponentsInChildren <ManipulatableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].transform.parent == mo.transform) { componentsInChildren[i].SetParent(sceneLayoutContainer); Assert.IsTrue(componentsInChildren[i].transform.parent == sceneLayoutContainer); } } }