Browse Source

Fungus _VariableData Drawer Indent Bug Fix

Use of EditorGUI to draw multiple items in 1 line that are all trying to honor indenting causing error. Now we cache first indent and temp set it to 0 for the remaining items.
Fix #802
master
Steve Halliwell 5 years ago
parent
commit
5b6bd550bf
  1. 13
      Assets/Fungus/Scripts/Editor/VariableEditor.cs

13
Assets/Fungus/Scripts/Editor/VariableEditor.cs

@ -236,21 +236,28 @@ namespace Fungus.EditorUtils
protected virtual void DrawSingleLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart,
VariableInfoAttribute typeInfo)
{
const int popupWidth = 17;
int popupWidth = Mathf.RoundToInt(EditorGUIUtility.singleLineHeight);
const int popupGap = 5;
//get out starting rect with intent honoured
Rect controlRect = EditorGUI.PrefixLabel(rect, label);
Rect valueRect = controlRect;
valueRect.width = controlRect.width - popupWidth - 5;
valueRect.width = controlRect.width - popupWidth - popupGap;
Rect popupRect = controlRect;
//we are overriding much of the auto layout to cram this all on 1 line so zero the intend and restore it later
var prevIndent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
if (referenceProp.objectReferenceValue == null)
{
DrawValueProperty(valueRect, valueProp, typeInfo);
popupRect.x += valueRect.width + 5;
popupRect.x += valueRect.width + popupGap;
popupRect.width = popupWidth;
}
EditorGUI.PropertyField(popupRect, referenceProp, new GUIContent(""));
EditorGUI.indentLevel = prevIndent;
}
protected virtual void DrawMultiLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart,

Loading…
Cancel
Save