public static EventType EndManipulationHandling() { EventType usedEvent = EndEventCheck(); if (usedEvent == EventType.MouseDown) { RecordMouseDownState(Selection.transforms); s_StartHandlePosition = Tools.handlePosition; s_PreviousHandlePosition = s_StartHandlePosition; s_StartLocalHandleOffset = Tools.localHandleOffset; if (s_LockHandle) { Tools.LockHandlePosition(); } Tools.LockHandleRectRotation(); } else if (s_MouseDownState != null && (usedEvent == EventType.MouseUp || GUIUtility.hotControl != s_HotControl)) { s_StartHandleRotation = Tools.handleRotation; s_MouseDownState = null; if (s_LockHandle) { Tools.UnlockHandlePosition(); } Tools.UnlockHandleRectRotation(); ManipulationToolUtility.DisableMinDragDifference(); } return(usedEvent); }
protected override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic) { TransformManipulator.BeginManipulationHandling(false); EditorGUI.BeginChangeCheck(); // The AimConstraint changes the rotation of the active object as the object is moved around in the scene. // This leads to very large "jumps" of the object, // as the move tool assumes the handle rotation to not change while the object is dragged. // Solution: when moving an object constrained with the AimConstraint, we ignore the rotation of the object. Quaternion handleRotation = Tools.handleRotation; var aimConstraintComponent = Selection.activeTransform.GetComponent <UnityEngine.Animations.AimConstraint>(); if (aimConstraintComponent != null && aimConstraintComponent.constraintActive) { handleRotation = TransformManipulator.mouseDownHandleRotation; } Vector3 pos2 = Handles.PositionHandle(handlePosition, handleRotation); if (EditorGUI.EndChangeCheck() && !isStatic && TransformManipulator.HandleHasMoved(pos2)) { ManipulationToolUtility.SetMinDragDifferenceForPos(handlePosition); if (Tools.vertexDragging) { ManipulationToolUtility.DisableMinDragDifference(); } TransformManipulator.SetPositionDelta(pos2, TransformManipulator.mouseDownHandlePosition); } TransformManipulator.EndManipulationHandling(); }
public static EventType EndManipulationHandling() { EventType eventType = TransformManipulator.EndEventCheck(); if (eventType == EventType.MouseDown) { TransformManipulator.RecordMouseDownState(Selection.transforms); TransformManipulator.s_StartHandlePosition = Tools.handlePosition; TransformManipulator.s_StartLocalHandleOffset = Tools.localHandleOffset; if (TransformManipulator.s_LockHandle) { Tools.LockHandlePosition(); } Tools.LockHandleRectRotation(); } else if (TransformManipulator.s_MouseDownState != null && (eventType == EventType.MouseUp || GUIUtility.hotControl != TransformManipulator.s_HotControl)) { TransformManipulator.s_MouseDownState = null; if (TransformManipulator.s_LockHandle) { Tools.UnlockHandlePosition(); } Tools.UnlockHandleRectRotation(); ManipulationToolUtility.DisableMinDragDifference(); } return(eventType); }
public override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic) { TransformManipulator.BeginManipulationHandling(false); EditorGUI.BeginChangeCheck(); Vector3 a = Handles.PositionHandle(handlePosition, Tools.handleRotation); if (EditorGUI.EndChangeCheck() && !isStatic) { Vector3 positionDelta = a - TransformManipulator.mouseDownHandlePosition; ManipulationToolUtility.SetMinDragDifferenceForPos(handlePosition); if (Tools.vertexDragging) { ManipulationToolUtility.DisableMinDragDifference(); } TransformManipulator.SetPositionDelta(positionDelta); } TransformManipulator.EndManipulationHandling(); }
public override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic) { TransformManipulator.BeginManipulationHandling(false); EditorGUI.BeginChangeCheck(); Quaternion rotation = Tools.handleRotation; AimConstraint component = Selection.activeTransform.GetComponent <AimConstraint>(); if (component != null && component.constraintActive) { rotation = TransformManipulator.mouseDownHandleRotation; } Vector3 vector = Handles.PositionHandle(handlePosition, rotation); if (EditorGUI.EndChangeCheck() && !isStatic && TransformManipulator.HandleHasMoved(vector)) { ManipulationToolUtility.SetMinDragDifferenceForPos(handlePosition); if (Tools.vertexDragging) { ManipulationToolUtility.DisableMinDragDifference(); } TransformManipulator.SetPositionDelta(vector, TransformManipulator.mouseDownHandlePosition); } TransformManipulator.EndManipulationHandling(); }