// Switch for switch functions (!) static void SwitchValues() { if (AlignEditor.ScaleTool) { Undo.RegisterUndo(Selection.transforms, "Switch Scale"); AlignManager.SwitchScale(Selection.transforms); } else if (AlignEditor.RotationTool) { Undo.RegisterUndo(Selection.transforms, "Switch Rotation"); AlignManager.SwitchRotation(Selection.transforms); } else { Undo.RegisterUndo(Selection.transforms, "Switch Position"); AlignManager.SwitchPosition(Selection.transforms); } }
// Update is called once per frame void Update() { if (!Input.GetKeyDown(KeyCode.Return)) { return; } int childCount = objectParent.GetChildCount(); if (objectParent != null && childCount > 0) { // We need to get all children separatly to tell the API that it must make every one of them fall, no the whole as if it were only one object Transform[] childs = new Transform[childCount]; for (int i = 0; i < childCount; i++) { childs[i] = objectParent.GetChild(i); } // Make them fall : list of object, true to set the normal from the hit, Collider to tell it to use the collider for raycast AlignManager.FallOnTerrain(childs, true, ExtentsGetter.BoundType.Collider); } }
// Switch for align functions static void Align() { if (Selection.transforms.Length == 0) { return; } if (AlignEditor.ScaleTool) { Undo.RegisterUndo(Selection.transforms, "Align Scale"); AlignManager.AlignScale(Selection.activeTransform, Selection.transforms, AlignEditor.Axis [(int)AlignEditor.axis], AlignEditor.landmark); } else if (AlignEditor.RotationTool) { Undo.RegisterUndo(Selection.transforms, "Align Rotation"); AlignManager.AlignRotation(Selection.activeTransform, Selection.transforms, AlignEditor.Axis [(int)AlignEditor.axis], AlignEditor.landmark); } else { Undo.RegisterUndo(Selection.transforms, "Align Position"); AlignManager.AlignPosition(Selection.activeTransform, Selection.transforms, AlignEditor.Axis [(int)AlignEditor.axis], AlignEditor.landmark, AlignEditor.PreferredBounds); } }
// Call for the fall on terrain feature, after calling the RegisterUndo static void FallOnTerrain() { Undo.RegisterSceneUndo("Fall on terrain"); AlignManager.FallOnTerrain(Selection.transforms, AlignEditor.rotateToTerrainAngle, AlignEditor.PreferredBounds); }