SetScaleDelta() 공개 정적인 메소드

public static SetScaleDelta ( Vector3 scaleDelta, Quaternion pivotRotation ) : void
scaleDelta Vector3
pivotRotation UnityEngine.Quaternion
리턴 void
예제 #1
0
        public override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic)
        {
            Quaternion targetRotation = (Selection.transforms.Length <= 1) ? Tools.handleLocalRotation : Tools.handleRotation;

            TransformManipulator.DebugAlignment(targetRotation);
            if (Event.current.type == EventType.MouseDown)
            {
                s_CurrentScale = Vector3.one;
            }
            EditorGUI.BeginChangeCheck();
            TransformManipulator.BeginManipulationHandling(true);
            s_CurrentScale = Handles.ScaleHandle(s_CurrentScale, handlePosition, targetRotation, HandleUtility.GetHandleSize(handlePosition));
            TransformManipulator.EndManipulationHandling();
            if (EditorGUI.EndChangeCheck() && !isStatic)
            {
                TransformManipulator.SetScaleDelta(s_CurrentScale, targetRotation);
            }
        }
예제 #2
0
        public override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic)
        {
            Quaternion quaternion = Selection.transforms.Length <= 1 ? Tools.handleLocalRotation : Tools.handleRotation;

            TransformManipulator.DebugAlignment(quaternion);
            if (Event.current.type == EventType.MouseDown)
            {
                ScaleTool.s_CurrentScale = Vector3.one;
            }
            EditorGUI.BeginChangeCheck();
            TransformManipulator.BeginManipulationHandling(true);
            ScaleTool.s_CurrentScale = Handles.ScaleHandle(ScaleTool.s_CurrentScale, handlePosition, quaternion, HandleUtility.GetHandleSize(handlePosition));
            int num = (int)TransformManipulator.EndManipulationHandling();

            if (!EditorGUI.EndChangeCheck() || isStatic)
            {
                return;
            }
            TransformManipulator.SetScaleDelta(ScaleTool.s_CurrentScale, quaternion);
        }
예제 #3
0
        protected override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic)
        {
            // Allow global space scaling for multi-selection but not for a single object
            Quaternion handleRotation = Selection.transforms.Length > 1 ?
                                        Tools.handleRotation : Tools.handleLocalRotation;

            TransformManipulator.DebugAlignment(handleRotation);

            if (Event.current.type == EventType.MouseDown)
            {
                s_CurrentScale = Vector3.one;
            }

            EditorGUI.BeginChangeCheck();

            TransformManipulator.BeginManipulationHandling(true);
            s_CurrentScale = Handles.ScaleHandle(s_CurrentScale, handlePosition, handleRotation, HandleUtility.GetHandleSize(handlePosition));
            TransformManipulator.EndManipulationHandling();

            if (EditorGUI.EndChangeCheck() && !isStatic)
            {
                TransformManipulator.SetScaleDelta(s_CurrentScale, handleRotation);
            }
        }
예제 #4
0
        protected override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic)
        {
            var ids = Handles.TransformHandleIds.Default;

            TransformManipulator.BeginManipulationHandling(false);

            // Lock position when scaling or rotating
            if (ids.scale.Has(GUIUtility.hotControl) ||
                ids.rotation.Has(GUIUtility.hotControl))
            {
                Tools.LockHandlePosition();
            }
            else
            {
                Tools.UnlockHandlePosition();
            }

            EditorGUI.BeginChangeCheck();

            if (Event.current.type == EventType.MouseDown)
            {
                s_Scale = Vector3.one;
            }

            var startPosition = handlePosition;
            var endPosition   = startPosition;
            var startRotation = Tools.handleRotation;
            var endRotation   = startRotation;
            var startScale    = s_Scale;
            var endScale      = startScale;

            Handles.TransformHandle(ids, ref endPosition, ref endRotation, ref endScale, Handles.TransformHandleParam.Default);
            s_Scale = endScale;

            if (EditorGUI.EndChangeCheck() && !isStatic)
            {
                Undo.RecordObjects(Selection.transforms, "Transform Manipulation");

                if (TransformManipulator.HandleHasMoved(endPosition))
                {
                    ManipulationToolUtility.SetMinDragDifferenceForPos(handlePosition);
                    TransformManipulator.SetPositionDelta(endPosition, TransformManipulator.mouseDownHandlePosition);
                }

                Quaternion deltaRotation = Quaternion.Inverse(startRotation) * endRotation;
                float      angle;
                Vector3    axis;
                deltaRotation.ToAngleAxis(out angle, out axis);
                if (!Mathf.Approximately(angle, 0))
                {
                    foreach (Transform t in Selection.transforms)
                    {
                        // Rotate around handlePosition (Global or Local axis).
                        if (Tools.pivotMode == PivotMode.Center)
                        {
                            t.RotateAround(handlePosition, startRotation * axis, angle);
                        }
                        // Local rotation (Pivot mode with Local axis).
                        else if (TransformManipulator.individualSpace)
                        {
                            t.Rotate(t.rotation * axis, angle, Space.World);
                        }
                        // Pivot mode with Global axis.
                        else
                        {
                            t.Rotate(startRotation * axis, angle, Space.World);
                        }

                        // sync euler hints after a rotate tool update tyo fake continuous rotation
                        t.SetLocalEulerHint(t.GetLocalEulerAngles(t.rotationOrder));

                        if (t.parent != null)
                        {
                            t.SendTransformChangedScale(); // force scale update, needed if tr has non-uniformly scaled parent.
                        }
                    }
                    Tools.handleRotation = endRotation;
                }

                if (endScale != startScale)
                {
                    TransformManipulator.SetScaleDelta(endScale, endRotation);
                }
            }
            TransformManipulator.EndManipulationHandling();
        }
예제 #5
0
        public override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic)
        {
            Handles.TransformHandleIds @default = Handles.TransformHandleIds.Default;
            TransformManipulator.BeginManipulationHandling(false);
            if (@default.scale.Has(GUIUtility.hotControl) || @default.rotation.Has(GUIUtility.hotControl))
            {
                Tools.LockHandlePosition();
            }
            else
            {
                Tools.UnlockHandlePosition();
            }
            EditorGUI.BeginChangeCheck();
            if (Event.current.type == EventType.MouseDown)
            {
                TransformTool.s_Scale = Vector3.one;
            }
            Vector3    vector         = handlePosition;
            Quaternion handleRotation = Tools.handleRotation;
            Quaternion quaternion     = handleRotation;
            Vector3    vector2        = TransformTool.s_Scale;
            Vector3    vector3        = vector2;

            Handles.TransformHandle(@default, ref vector, ref quaternion, ref vector3, Handles.TransformHandleParam.Default);
            TransformTool.s_Scale = vector3;
            if (EditorGUI.EndChangeCheck() && !isStatic)
            {
                Undo.RecordObjects(Selection.transforms, "Transform Manipulation");
                if (TransformManipulator.HandleHasMoved(vector))
                {
                    ManipulationToolUtility.SetMinDragDifferenceForPos(handlePosition);
                    TransformManipulator.SetPositionDelta(vector, TransformManipulator.mouseDownHandlePosition);
                }
                float   num;
                Vector3 point;
                (Quaternion.Inverse(handleRotation) * quaternion).ToAngleAxis(out num, out point);
                if (!Mathf.Approximately(num, 0f))
                {
                    Transform[] transforms = Selection.transforms;
                    for (int i = 0; i < transforms.Length; i++)
                    {
                        Transform transform = transforms[i];
                        if (Tools.pivotMode == PivotMode.Center)
                        {
                            transform.RotateAround(handlePosition, handleRotation * point, num);
                        }
                        else if (TransformManipulator.individualSpace)
                        {
                            transform.Rotate(transform.rotation * point, num, Space.World);
                        }
                        else
                        {
                            transform.Rotate(handleRotation * point, num, Space.World);
                        }
                        transform.SetLocalEulerHint(transform.GetLocalEulerAngles(transform.rotationOrder));
                        if (transform.parent != null)
                        {
                            transform.SendTransformChangedScale();
                        }
                    }
                    Tools.handleRotation = quaternion;
                }
                if (vector3 != vector2)
                {
                    TransformManipulator.SetScaleDelta(vector3, quaternion);
                }
            }
            TransformManipulator.EndManipulationHandling();
        }