private void RotationGUI() { Rect r = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight + 24 + EditorGUIUtility.standardVerticalSpacing); Rect line = r; line.height = EditorGUIUtility.singleLineHeight; float x = (line.width - 10f) / 2; float fieldWidth = x / 2 - 10f; float labelWidth = x - fieldWidth; line.width = labelWidth; EditorGUI.LabelField(line, "Rotation"); line.x += labelWidth; line.width = r.width - labelWidth - 78; string[] options = spConstrainRotation.hasMultipleDifferentValues? new [] { "---", "---" } : new [] { "Free", "Constrained" }; bool boolVal = spConstrainRotation.boolValue; EditorGUI.BeginChangeCheck(); { boolVal = GUI.Toolbar(line, boolVal ? 1 : 0, options) == 1; } if (EditorGUI.EndChangeCheck()) { spConstrainRotation.boolValue = boolVal; GUI.FocusControl(null); } line.x += line.width + 14; line.width = 64; EditorGUI.LabelField(line, "Flip"); line.y += EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.singleLineHeight; line.x = r.x + 10; line.height = EditorGUIUtility.singleLineHeight; line.width = labelWidth - 10; EditorGUI.BeginDisabledGroup(spConstrainRotation.boolValue); { Rect dragZone = line; EditorGUI.LabelField(line, "Angle"); line.x = r.x + labelWidth; line.width = r.width - labelWidth - 148; float rotationValue = spShapeRotation.floatValue; EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = spShapeRotation.hasMultipleDifferentValues; rotationValue = EditorGUILayoutExtended.FloatFieldExtended(line, spShapeRotation.floatValue, dragZone); EditorGUI.showMixedValue = false; } if (EditorGUI.EndChangeCheck()) { spShapeRotation.floatValue = rotationValue; } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!spConstrainRotation.boolValue); { line.x += line.width + 4; line.width = 30; line.height = 24; if (GUI.Button(line, MPEditorStyles.RotateLeftNormal)) { float rotation = spShapeRotation.floatValue; float remainder = rotation % 90; if (Mathf.Abs(remainder) <= 0) { rotation += 90; } else { rotation = rotation - remainder + 90; } if (Math.Abs(rotation) >= 360) { rotation = 0; } spShapeRotation.floatValue = rotation; } line.x += 34; if (GUI.Button(line, MPEditorStyles.RotateRightNormal)) { float rotation = spShapeRotation.floatValue; float remainder = rotation % 90; if (Mathf.Abs(remainder) <= 0) { rotation -= 90; } else { rotation -= remainder; } if (Math.Abs(rotation) >= 360) { rotation = 0; } spShapeRotation.floatValue = rotation; } } EditorGUI.EndDisabledGroup(); line.x += 46; bool flipH = spFlipHorizontal.boolValue; bool flipV = spFlipVertical.boolValue; EditorGUI.BeginChangeCheck(); { EditorGUI.BeginDisabledGroup(spFlipHorizontal.hasMultipleDifferentValues || spFlipVertical.hasMultipleDifferentValues); flipH = GUI.Toggle(line, spFlipHorizontal.boolValue, spFlipHorizontal.boolValue ? MPEditorStyles.FlipHorizontalActive:MPEditorStyles.FlipHorizontalNormal, "button"); line.x += 34; flipV = GUI.Toggle(line, spFlipVertical.boolValue, spFlipVertical.boolValue?MPEditorStyles.FlipVerticalActive:MPEditorStyles.FlipVerticalNormal, "button"); EditorGUI.EndDisabledGroup(); } if (EditorGUI.EndChangeCheck()) { spFlipHorizontal.boolValue = flipH; spFlipVertical.boolValue = flipV; } }
private void AdditionalShapeDataGUI() { EditorGUILayout.Space(); float strokeWidth = spStrokeWidth.floatValue; float outlineWidth = spOutlineWidth.floatValue; float falloff = spFalloffDistance.floatValue; Color outlineColor = spOutlineColor.colorValue; Rect r = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing); Rect line = r; line.height = EditorGUIUtility.singleLineHeight; float x = (line.width - 10f) / 2; float fieldWidth = x / 2 - 10f; float labelWidth = x - fieldWidth; line.width = labelWidth; EditorGUI.LabelField(line, "Stroke"); Rect dragZone = line; line.x += labelWidth; line.width = fieldWidth; EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = spStrokeWidth.hasMultipleDifferentValues; strokeWidth = EditorGUILayoutExtended.FloatFieldExtended(line, spStrokeWidth.floatValue, dragZone); EditorGUI.showMixedValue = false; } if (EditorGUI.EndChangeCheck()) { spStrokeWidth.floatValue = strokeWidth; } line.x += fieldWidth + 10; line.width = labelWidth; EditorGUI.LabelField(line, "Falloff"); dragZone = line; line.x += labelWidth; line.width = fieldWidth; EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = spFalloffDistance.hasMultipleDifferentValues; falloff = EditorGUILayoutExtended.FloatFieldExtended(line, spFalloffDistance.floatValue, dragZone); EditorGUI.showMixedValue = false; } if (EditorGUI.EndChangeCheck()) { spFalloffDistance.floatValue = falloff; } line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; line.x = r.x; line.width = labelWidth; EditorGUI.LabelField(line, "Outline Width"); dragZone = line; line.x += labelWidth; line.width = fieldWidth; EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = spOutlineWidth.hasMultipleDifferentValues; outlineWidth = EditorGUILayoutExtended.FloatFieldExtended(line, spOutlineWidth.floatValue, dragZone); EditorGUI.showMixedValue = false; } if (EditorGUI.EndChangeCheck()) { spOutlineWidth.floatValue = outlineWidth; } line.x += fieldWidth + 10; line.width = labelWidth; EditorGUI.LabelField(line, "Outline Color"); dragZone = line; line.width = fieldWidth; line.x += labelWidth; EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = spOutlineColor.hasMultipleDifferentValues; outlineColor = EditorGUI.ColorField(line, spOutlineColor.colorValue); EditorGUI.showMixedValue = false; } if (EditorGUI.EndChangeCheck()) { spOutlineColor.colorValue = outlineColor; } EditorGUILayout.Space(); RotationGUI(); }