private void DrawAngleHandle(BendDeformer bend) { var handleRotation = bend.Axis.rotation * Quaternion.Euler(-90, 0f, 0f); // There's some weird issue where if you pass the normal lossyScale, the handle's scale on the y axis is changed when the transform's z axis is changed. // My simple solution is to swap the y and z. var handleScale = new Vector3 ( x: bend.Axis.lossyScale.x, y: bend.Axis.lossyScale.z, z: bend.Axis.lossyScale.y ); var matrix = Matrix4x4.TRS(bend.Axis.position + bend.Axis.up * bend.Bottom * bend.Axis.lossyScale.y, handleRotation, handleScale); var radiusDistanceOffset = HandleUtility.GetHandleSize(bend.Axis.position + bend.Axis.up * bend.Top) * DeformEditorSettings.ScreenspaceSliderHandleCapSize * 2f; angleHandle.angle = bend.Angle; angleHandle.radius = (bend.Top - bend.Bottom) + radiusDistanceOffset; angleHandle.fillColor = Color.clear; using (new Handles.DrawingScope(DeformEditorSettings.SolidHandleColor, matrix)) { using (var check = new EditorGUI.ChangeCheckScope()) { angleHandle.DrawHandle(); if (check.changed) { Undo.RecordObject(bend, "Changed Angle"); bend.Angle = angleHandle.angle; } } } }
private void Awake() { _bendDeformer = GetComponent <BendDeformer>(); }