Пример #1
0
        private void Update(bool symmetricScale)
        {
            if (Shape == null)
            {
                return;
            }

            ShapeUtils utils = Shape.GetUtils();

            if (utils == null)
            {
                return;
            }

            Undo.RecordObject(Shape, "ShapeResizeTool");
            Undo.RecordObject(Shape.transform, "ShapeResizeToolTransform");

            Color color = Color.gray;
            float scale = 0.35f;

            foreach (ShapeUtils.Direction dir in System.Enum.GetValues(typeof(ShapeUtils.Direction)))
            {
                Vector3 delta = DeltaSliderTool(utils.GetWorldFace(dir), utils.GetWorldFaceDirection(dir), color, scale);
                if (delta.magnitude > 1.0E-5f)
                {
                    Vector3 localSizeChange    = Shape.transform.InverseTransformDirection(delta);
                    Vector3 localPositionDelta = 0.5f * localSizeChange;
                    if (!symmetricScale && utils.IsHalfSize(dir))
                    {
                        localSizeChange *= 0.5f;
                    }

                    utils.UpdateSize(localSizeChange, dir);

                    if (!symmetricScale)
                    {
                        Shape.transform.position += Shape.transform.TransformDirection(localPositionDelta);
                    }
                }
            }
        }