UnityEditor.TransformManipulator.SetPositionDelta C# (CSharp) Method

SetPositionDelta() public static method

public static SetPositionDelta ( Vector3 positionDelta ) : void
positionDelta Vector3
return void
        public static void SetPositionDelta(Vector3 positionDelta)
        {
            if (s_MouseDownState != null)
            {
                for (int i = 0; i < s_MouseDownState.Length; i++)
                {
                    TransformData data = s_MouseDownState[i];
                    Undo.RecordObject((data.rectTransform == null) ? data.transform : data.rectTransform, "Move");
                }
                for (int j = 0; j < s_MouseDownState.Length; j++)
                {
                    s_MouseDownState[j].SetPositionDelta(positionDelta);
                }
            }
        }

Usage Example

示例#1
0
        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();
        }
All Usage Examples Of UnityEditor.TransformManipulator::SetPositionDelta