Exemple #1
0
        public static void ScaleHandle(ShapeSO scriptableObject, Shape shape)
        {
            Vector3 scale     = shape.scale;
            float   magnitude = shape.scale.sqrMagnitude;

            EditorGUI.BeginChangeCheck();

            scale = Handles.ScaleHandle(scale, shape.position, shape.Rotation, magnitude);

            if (EditorGUI.EndChangeCheck())
            {
                shape.scale = scale;
                Undo.RegisterCompleteObjectUndo(scriptableObject, "Scaled shape");
            }
        }
Exemple #2
0
        public static void TransformHandle(ShapeSO scriptableObject, Shape shape)
        {
            Vector3    position = shape.position;
            Quaternion rotation = shape.Rotation;
            Vector3    scale    = shape.scale;

            EditorGUI.BeginChangeCheck();

            Handles.TransformHandle(ref position, ref rotation, ref scale);

            if (EditorGUI.EndChangeCheck())
            {
                shape.position = position;
                shape.Rotation = rotation;
                shape.scale    = scale;
                Undo.RegisterCompleteObjectUndo(scriptableObject, "Transformed shape");
            }
        }
Exemple #3
0
        public static void DrawHandles(ShapeSO scriptableObject, Shape shape, Tool tool)
        {
            switch (tool)
            {
            case Tool.Move:
                MoveHandle(scriptableObject, shape);
                break;

            case Tool.Rotate:
                RotateHandle(scriptableObject, shape);
                break;

            case Tool.Scale:
                ScaleHandle(scriptableObject, shape);
                break;

            case Tool.Transform:
                TransformHandle(scriptableObject, shape);
                break;
            }
        }