コード例 #1
0
        private void DrawFactorHandle(SpherifyDeformer spherify)
        {
            if (spherify.Radius == 0f)
            {
                return;
            }

            var direction = Vector3.forward;
            var position  = direction * (spherify.Factor * spherify.Radius);

            using (new Handles.DrawingScope(Matrix4x4.TRS(spherify.Axis.position, spherify.Axis.rotation, spherify.Axis.lossyScale)))
            {
                DeformHandles.Line(Vector3.zero, position, DeformHandles.LineMode.Light);
                DeformHandles.Line(position, direction * spherify.Radius, DeformHandles.LineMode.LightDotted);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newWorldPosition = DeformHandles.Slider(position, direction);
                    if (check.changed)
                    {
                        Undo.RecordObject(spherify, "Changed Factor");
                        var newFactor = newWorldPosition.z / spherify.Radius;
                        spherify.Factor = newFactor;
                    }
                }
            }
        }
コード例 #2
0
 private void DrawRadiusHandle(SpherifyDeformer spherify)
 {
     using (new Handles.DrawingScope(Matrix4x4.TRS(spherify.Axis.position, spherify.Axis.rotation, spherify.Axis.lossyScale)))
     {
         using (var check = new EditorGUI.ChangeCheckScope())
         {
             var newRadius = DeformHandles.Radius(Quaternion.identity, Vector3.zero, spherify.Radius);
             if (check.changed)
             {
                 Undo.RecordObject(spherify, "Changed Radius");
                 spherify.Radius = newRadius;
             }
         }
     }
 }