mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 08:08:51 -05:00
Fix indentation bug in variable drawer (#109)
This commit is contained in:
parent
630d45bceb
commit
ed856beb11
@ -14,15 +14,29 @@ namespace UnityAtoms.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
position = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
var inner = new SerializedObject(property.objectReferenceValue);
|
||||
var valueProp = inner.FindProperty("_value");
|
||||
var width = GetPreviewSpace(valueProp.type) + (property.depth == 0 ? EditorGUIUtility.labelWidth : 0);
|
||||
var restRect = IMGUIUtils.SnipRectH(position, width, out position, 6f);
|
||||
base.OnGUI(position, property, GUIContent.none);
|
||||
var width = GetPreviewSpace(valueProp.type);
|
||||
Rect previewRect = new Rect(position);
|
||||
previewRect.width = GetPreviewSpace(valueProp.type);
|
||||
position.xMin = previewRect.xMax;
|
||||
|
||||
int indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUI.PropertyField(restRect, valueProp, label, false);
|
||||
EditorGUI.PropertyField(previewRect, valueProp, GUIContent.none, false);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
position.x = position.x + 6f;
|
||||
position.width = position.width - 6f;
|
||||
base.OnGUI(position, property, GUIContent.none);
|
||||
|
||||
EditorGUI.indentLevel = indent;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
private float GetPreviewSpace(string type)
|
||||
|
Loading…
Reference in New Issue
Block a user