private void RenderAssignSelectionToLayerButton() { if (GUILayout.Button(GetContentForAssignSelectionToLayerButton(), GUILayout.Width(110.0f))) { ObjectSelectionActions.AssignSelectedObjectsToLayer(ViewData.SelectionAssignmentLayer); } }
private void RenderInvertSelectionButton() { if (GUILayout.Button(GetContentForInvertSelection(), GUILayout.Width(110.0f))) { UndoEx.RecordForToolAction(ObjectSelection.Get()); ObjectSelectionActions.InvertSelection(); } }
private void RenderDeselectActiveLayerButton() { if (GUILayout.Button(GetContentForDeselectActiveLayerButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth * _actionButtonScale))) { UndoEx.RecordForToolAction(ObjectSelection.Get()); ObjectSelectionActions.DeselectAllObjectsInLayer(_database.ActiveLayer); } }
private void RenderSelectAllLayersButton() { if (GUILayout.Button(GetContentForSelectAllLayersButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth * _actionButtonScale))) { UndoEx.RecordForToolAction(ObjectSelection.Get()); ObjectSelectionActions.SelectAllObjectsInAllLayers(); } }
public void HandleExecuteCommandEvent(Event e) { if (e.IsDuplicateSelectionCommand()) { e.DisableInSceneView(); UndoEx.RecordForToolAction(this); ObjectSelectionActions.DuplicateSelection(); } }
public void ReplaceSelectedObjectsWithPrefab(Prefab prefab) { if (prefab == null || prefab.UnityPrefab == null || NumberOfSelectedObjects == 0) { return; } UndoEx.RecordForToolAction(this); ObjectSelectionActions.ReplaceSelectedObjectsWithPrefab(prefab.UnityPrefab); }
protected override void RenderContent() { EditorGUILayoutEx.BeginVerticalBox(); EditorGUILayout.BeginHorizontal(); const float alignButtonWidth = 72.0f; var content = new GUIContent(); content.text = "Align X"; content.tooltip = "Aligns the positions of the selected objects to the X axis."; if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth))) { ObjectSelectionActions.AlignSelectionToAxis(Axis.X); } content.text = "Align Y"; content.tooltip = "Aligns the positions of the selected objects to the Y axis."; if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth))) { ObjectSelectionActions.AlignSelectionToAxis(Axis.Y); } content.text = "Align Z"; content.tooltip = "Aligns the positions of the selected objects to the Z axis."; if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth))) { ObjectSelectionActions.AlignSelectionToAxis(Axis.Z); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderMakeSelectionStaticButton(); RenderMakeSelectionDynamicButton(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderInvertSelectionButton(); content.text = "Grab settings..."; content.tooltip = "Opens up a new window which allows you to modify selection grab settings."; if (GUILayout.Button(content, GUILayout.Width(110.0f))) { Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.SelectionGrabSettingsWindow.ObjectGrabSettings = ObjectSelection.Get().SelectionGrabSettings; Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.SelectionGrabSettingsWindow.ShowOctave3DWindow(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderAssignSelectionToLayerButton(); RenderSelectionAssignmentLayerSelectionPopup(); EditorGUILayout.EndHorizontal(); EditorGUILayoutEx.EndVerticalBox(); }
public void HandleMouseButtonDownEvent(Event e) { if (_object2ObjectSnapSession.IsActive && AllShortcutCombos.Instance.EndSelectionObject2ObjectSnap.IsActive()) { e.DisableInSceneView(); _object2ObjectSnapSession.End(); return; } if (_selectionGridSnapSession.IsActive || _selectionGrabSession.IsActive || _object2ObjectSnapSession.IsActive || _objectVertexSnapSession.IsActive) { return; } if (AllShortcutCombos.Instance.SnapXZGridToCursorPickPointOnLeftClick_Selection.IsActive() && e.InvolvesLeftMouseButton()) { e.DisableInSceneView(); ObjectSnapping.Get().SnapXZGridToCursorPickPoint(e.clickCount == 2); return; } if (Mirror.IsInteractionSessionActive && e.InvolvesLeftMouseButton()) { e.DisableInSceneView(); Mirror.EndInteractionSession(); return; } if (e.InvolvesLeftMouseButton() && NumberOfSelectedObjects != 0 && !SelectionShape.IsVisible() && AllShortcutCombos.Instance.ReplacePrefabsForSelectedObjects_Scene.IsActive() && !Mirror.IsInteractionSessionActive) { e.DisableInSceneView(); UndoEx.RecordForToolAction(this); List <GameObject> newObjects = ObjectSelectionActions.ReplaceSelectedObjectsPrefabOnMouseClick(); if (newObjects.Count != 0) { AddGameObjectCollectionToSelection(newObjects); } return; } SelectionShape.HandleMouseButtonDownEvent(e); if (CanPerformClickSelectionUpdateOperation()) { var clickSelectionUpdateOperation = ObjectSelectionUpdateOperationFactory.Create(ObjectSelectionUpdateOperationType.Click); clickSelectionUpdateOperation.Perform(); SceneView.RepaintAll(); } }
public override void Perform() { if (Event.current.InvolvesLeftMouseButton()) { Event.current.DisableInSceneView(); MouseCursorRayHit cursorRayHit = ObjectSelection.Get().GetObjectPickedByCursor(); if (cursorRayHit.WasAnObjectHit) { GameObject closestHitObject = cursorRayHit.SortedObjectRayHits[0].HitObject; if (cursorRayHit.WasLightObjectHit || cursorRayHit.WasParticleSystemHit) { closestHitObject = cursorRayHit.GetClosestHitParticleSystemOrLightObject(); } // Note: If append mode is enabled, we will toggle the selected state of the picked object. Otherwise, // we will clear the current selection and select only the picked game object. if (AllShortcutCombos.Instance.EnableAppendObjectsToSelection.IsActive()) { ToggleObjectSelectedState(closestHitObject); } else { ClearSelectionAndSelectObject(closestHitObject); } if (Event.current.clickCount == 2) { UndoEx.RecordForToolAction(ObjectSelection.Get()); ObjectSelectionActions.SelectAllObjectsWithSamePrefabAsObject(closestHitObject); ObjectSelection.Get().ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick(); } } else { ClearSelectionWhenNoObjectPicked(); } } }
public void HandleKeyboardButtonDownEvent(Event e) { if (AllShortcutCombos.Instance.GrabSelection.IsActive() && NumberOfSelectedObjects != 0) { if (_selectionGrabSession.IsActive) { _selectionGrabSession.End(); } else { _selectionGrabSession.Settings = SelectionGrabSettings; _selectionGrabSession.Begin(new List <GameObject>(_selectedObjects.HashSet)); } } if (_selectionGrabSession.IsActive || _selectionSnapSession.IsActive) { return; } // Note: Don't disable this event if it's CTRL or CMD because transform // handle snapping will no longer work. if (e.keyCode != KeyCode.LeftControl && e.keyCode != KeyCode.LeftCommand && e.keyCode != KeyCode.RightControl && e.keyCode != KeyCode.RightCommand) { e.DisableInSceneView(); } if (Mirror.IsInteractionSessionActive) { Mirror.HandleKeyboardButtonDownEvent(e); return; } if (Mirror.IsActive && AllShortcutCombos.Instance.MirrorSelectedObjects.IsActive()) { List <GameObject> topParentsInSelectedObjects = GameObjectExtensions.GetTopParentsFromGameObjectCollection(_selectedObjects.HashSet); ObjectHierarchyRootsWerePlacedInSceneMessage.SendToInterestedListeners(Mirror.MirrorGameObjectHierarchies(topParentsInSelectedObjects), ObjectHierarchyRootsWerePlacedInSceneMessage.PlacementType.MirroredSelection); return; } if (AllShortcutCombos.Instance.DeleteSelectedObjects.IsActive()) { UndoEx.RecordForToolAction(this); ObjectActions.EraseAllSelectedGameObjects(); } else if (AllShortcutCombos.Instance.SelectAllObjectsWithSamePrefabAsCurrentSelection.IsActive()) { UndoEx.RecordForToolAction(this); ObjectSelectionActions.SelectAllObjectsWithSamePrefabAsCurrentSelection(); _objectSelectionTransformGizmoSystem.OnObjectSelectionUpdated(); } else if (AllShortcutCombos.Instance.ToggleGizmosOnOff.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionTransformGizmoSystem); _objectSelectionTransformGizmoSystem.AreGizmosActive = !_objectSelectionTransformGizmoSystem.AreGizmosActive; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ActivateMoveGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionTransformGizmoSystem); _objectSelectionTransformGizmoSystem.ActiveGizmoType = TransformGizmoType.Move; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ActivateRotationGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionTransformGizmoSystem); _objectSelectionTransformGizmoSystem.ActiveGizmoType = TransformGizmoType.Rotate; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ActivateScaleGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionTransformGizmoSystem); _objectSelectionTransformGizmoSystem.ActiveGizmoType = TransformGizmoType.Scale; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ProjectSelectedObjects.IsActive()) { ProjectSelectionOnProjectionSurface(); } else if (AllShortcutCombos.Instance.SnapSelection.IsActive()) { _selectionSnapSession.Begin(); } }
public void HandleKeyboardButtonDownEvent(Event e) { if (AllShortcutCombos.Instance.ActivateObjectVertexSnapSession_Placement.IsActive() && !_object2ObjectSnapSession.IsActive && !_selectionGrabSession.IsActive && !SelectionShape.IsVisible()) { e.DisableInSceneView(); _objectVertexSnapSession.Begin(GetAllSelectedGameObjects()); return; } if (!_object2ObjectSnapSession.IsActive) { if (AllShortcutCombos.Instance.GrabSelection.IsActive() && NumberOfSelectedObjects != 0) { if (_selectionGrabSession.IsActive) { _selectionGrabSession.End(); } else { _selectionGrabSession.Settings = SelectionGrabSettings; _selectionGrabSession.Begin(new List <GameObject>(_selectedObjects.HashSet)); } } } if (!_selectionGrabSession.IsActive) { if (AllShortcutCombos.Instance.ToggleSelectionObject2ObjectSnap.IsActive() && NumberOfSelectedObjects != 0) { if (_object2ObjectSnapSession.IsActive) { _object2ObjectSnapSession.End(); } else { _object2ObjectSnapSession.Begin(); } } } if (_object2ObjectSnapSession.IsActive) { if (AllShortcutCombos.Instance.SelectionRotateWorldX.IsActive()) { Rotate(Settings.XRotationStep, Vector3.right); } else if (AllShortcutCombos.Instance.SelectionRotateWorldY.IsActive()) { Rotate(Settings.YRotationStep, Vector3.up); } else if (AllShortcutCombos.Instance.SelectionRotateWorldZ.IsActive()) { Rotate(Settings.ZRotationStep, Vector3.forward); } else if (AllShortcutCombos.Instance.SetRotationToIdentity.IsActive()) { SetWorldRotation(Quaternion.identity); } return; } if (_selectionGrabSession.IsActive || _selectionGridSnapSession.IsActive || _object2ObjectSnapSession.IsActive) { return; } // Note: Don't disable this event if it's CTRL or CMD because transform // handle snapping will no longer work. if (e.keyCode != KeyCode.LeftControl && e.keyCode != KeyCode.LeftCommand && e.keyCode != KeyCode.RightControl && e.keyCode != KeyCode.RightCommand) { e.DisableInSceneView(); } if (Mirror.IsInteractionSessionActive) { Mirror.HandleKeyboardButtonDownEvent(e); return; } if (Mirror.IsActive && AllShortcutCombos.Instance.MirrorSelectedObjects.IsActive()) { List <GameObject> selectedRoots = Octave3DWorldBuilder.ActiveInstance.GetRoots(GetAllSelectedGameObjects()); ObjectHierarchyRootsWerePlacedInSceneMessage.SendToInterestedListeners(Mirror.MirrorGameObjectHierarchies(selectedRoots), ObjectHierarchyRootsWerePlacedInSceneMessage.PlacementType.Selection); return; } if (AllShortcutCombos.Instance.DeleteSelectedObjects.IsActive()) { UndoEx.RecordForToolAction(this); ObjectActions.EraseAllSelectedGameObjects(); } else if (AllShortcutCombos.Instance.SelectAllObjectsWithSamePrefabAsCurrentSelection.IsActive()) { UndoEx.RecordForToolAction(this); ObjectSelectionActions.SelectAllObjectsWithSamePrefabAsCurrentSelection(); _objectSelectionGizmos.OnObjectSelectionUpdated(); } else if (AllShortcutCombos.Instance.ActivateMoveGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionGizmos); _objectSelectionGizmos.ActiveGizmoType = GizmoType.Move; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ActivateRotationGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionGizmos); _objectSelectionGizmos.ActiveGizmoType = GizmoType.Rotate; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ActivateScaleGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionGizmos); _objectSelectionGizmos.ActiveGizmoType = GizmoType.Scale; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ActivateObjectSelectionExtrudeGizmo.IsActive()) { UndoEx.RecordForToolAction(_objectSelectionGizmos); _objectSelectionGizmos.ActiveGizmoType = GizmoType.Duplicate; Octave3DWorldBuilder.ActiveInstance.Inspector.EditorWindow.Repaint(); } else if (AllShortcutCombos.Instance.ProjectSelectedObjects.IsActive()) { ProjectSelectionOnProjectionSurface(); } else if (AllShortcutCombos.Instance.SelectionGridSnap.IsActive()) { _selectionGridSnapSession.Begin(); } else if (AllShortcutCombos.Instance.SetRotationToIdentity.IsActive()) { SetWorldRotation(Quaternion.identity); } else if (AllShortcutCombos.Instance.SelectionRotateWorldX.IsActive()) { Rotate(Settings.XRotationStep, Vector3.right); } else if (AllShortcutCombos.Instance.SelectionRotateWorldY.IsActive()) { Rotate(Settings.YRotationStep, Vector3.up); } else if (AllShortcutCombos.Instance.SelectionRotateWorldZ.IsActive()) { Rotate(Settings.ZRotationStep, Vector3.forward); } }
protected override void RenderContent() { EditorGUILayoutEx.BeginVerticalBox(); EditorGUILayout.BeginHorizontal(); const float alignButtonWidth = 72.0f; var content = new GUIContent(); content.text = "Align X"; content.tooltip = "Aligns the positions of the selected objects to the X axis."; if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth))) { ObjectSelectionActions.AlignSelectionToAxis(Axis.X); } content.text = "Align Y"; content.tooltip = "Aligns the positions of the selected objects to the Y axis."; if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth))) { ObjectSelectionActions.AlignSelectionToAxis(Axis.Y); } content.text = "Align Z"; content.tooltip = "Aligns the positions of the selected objects to the Z axis."; if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth))) { ObjectSelectionActions.AlignSelectionToAxis(Axis.Z); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderMakeSelectionStaticButton(); RenderMakeSelectionDynamicButton(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderInvertSelectionButton(); content.text = "Grab settings..."; content.tooltip = "Opens up a new window which allows you to modify selection grab settings."; if (GUILayout.Button(content, GUILayout.Width(110.0f))) { Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.SelectionGrabSettingsWindow.ObjectGrabSettings = ObjectSelection.Get().SelectionGrabSettings; Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.SelectionGrabSettingsWindow.ShowOctave3DWindow(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderAssignSelectionToLayerButton(); RenderSelectionAssignmentLayerSelectionPopup(); EditorGUILayout.EndHorizontal(); if (ObjectGroupDatabase.Get().NumberOfGroups != 0) { if (string.IsNullOrEmpty(ViewData.DestObjectGroupName)) { ViewData.DestObjectGroupName = ObjectGroupDatabase.Get().GetObjectGroupByIndex(0).Name; } else { if (ObjectGroupDatabase.Get().GetObjectGroupByName(ViewData.DestObjectGroupName) == null) { ViewData.DestObjectGroupName = ObjectGroupDatabase.Get().GetObjectGroupByIndex(0).Name; } } EditorGUILayout.BeginHorizontal(); content.text = "Assign to group"; content.tooltip = "Assigns the object selection to the specified object group."; if (GUILayout.Button(content, GUILayout.Width(110.0f))) { ObjectGroup destObjectGroup = ObjectGroupDatabase.Get().GetObjectGroupByName(ViewData.DestObjectGroupName); if (destObjectGroup != null) { ObjectActions.AssignObjectsToGroup(ObjectSelection.Get().GetAllSelectedGameObjects(), destObjectGroup); } } string newGroupName = EditorGUILayoutEx.Popup(new GUIContent(), ViewData.DestObjectGroupName, ObjectGroupDatabase.Get().GetAllObjectGroupNames()); if (newGroupName != ViewData.DestObjectGroupName) { UndoEx.RecordForToolAction(ViewData); ViewData.DestObjectGroupName = newGroupName; } EditorGUILayout.EndHorizontal(); } EditorGUILayoutEx.EndVerticalBox(); }