Skip to content

Commit 0c5b8f4

Browse files
committed
Fix InlineEditor preview layout
1 parent 19b6729 commit 0c5b8f4

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

Editor.Extras/Drawers/InlineEditorDrawer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public override TriElement CreateElement(TriProperty property, TriElement next)
3434
{
3535
mode = Attribute.Mode,
3636
previewHeight = Attribute.PreviewHeight,
37-
previewWidth = Attribute.PreviewWidth,
3837
}));
3938
return element;
4039
}

Editor/Elements/InlineEditorElement.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class InlineEditorElement : TriElement
1616
public struct Props
1717
{
1818
public InlineEditorModes mode;
19-
public float previewWidth;
2019
public float previewHeight;
2120

2221
public bool DrawGUI => (mode & InlineEditorModes.GUIOnly) != 0;
@@ -95,7 +94,7 @@ public override void OnGUI(Rect position)
9594
if (_editor != null && shouldDrawEditor)
9695
{
9796
GUILayout.BeginArea(_editorPosition);
98-
GUILayout.BeginHorizontal();
97+
GUILayout.BeginVertical();
9998

10099
if (_props.DrawHeader || _props.DrawGUI)
101100
{
@@ -122,13 +121,8 @@ public override void OnGUI(Rect position)
122121
{
123122
GUILayout.BeginVertical();
124123

125-
var horizontal = _props.DrawHeader || _props.DrawGUI;
126-
127-
var previewOpts = horizontal
128-
? new[] {GUILayout.Width(_props.previewWidth), GUILayout.ExpandHeight(true),}
129-
: new[] {GUILayout.ExpandWidth(true), GUILayout.Height(_props.previewHeight),};
130-
131-
var previewRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, previewOpts);
124+
var previewOpts = new[] {GUILayout.ExpandWidth(true), GUILayout.Height(_props.previewHeight),};
125+
var previewRect = EditorGUILayout.GetControlRect(false, _props.previewHeight, previewOpts);
132126

133127
previewRect.width = Mathf.Max(previewRect.width, 10);
134128
previewRect.height = Mathf.Max(previewRect.height, 10);
@@ -143,7 +137,7 @@ public override void OnGUI(Rect position)
143137
GUILayout.EndVertical();
144138
}
145139

146-
GUILayout.EndHorizontal();
140+
GUILayout.EndVertical();
147141
lastEditorRect = GUILayoutUtility.GetLastRect();
148142
GUILayout.EndArea();
149143
}

Runtime/Attributes/InlineEditorAttribute.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class InlineEditorAttribute : Attribute
1010
{
1111
public InlineEditorModes Mode { get; set; } = InlineEditorModes.GUIOnly;
1212

13-
public float PreviewWidth { get; set; } = 100;
1413
public float PreviewHeight { get; set; } = 50;
1514

1615
public InlineEditorAttribute()

0 commit comments

Comments
 (0)