Fix InlineEditor preview layout

This commit is contained in:
VladV 2024-04-06 13:11:25 +03:00
parent 19b6729b97
commit 0c5b8f4480
3 changed files with 4 additions and 12 deletions

View File

@ -34,7 +34,6 @@ namespace TriInspector.Drawers
{
mode = Attribute.Mode,
previewHeight = Attribute.PreviewHeight,
previewWidth = Attribute.PreviewWidth,
}));
return element;
}

View File

@ -16,7 +16,6 @@ namespace TriInspector.Elements
public struct Props
{
public InlineEditorModes mode;
public float previewWidth;
public float previewHeight;
public bool DrawGUI => (mode & InlineEditorModes.GUIOnly) != 0;
@ -95,7 +94,7 @@ namespace TriInspector.Elements
if (_editor != null && shouldDrawEditor)
{
GUILayout.BeginArea(_editorPosition);
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
if (_props.DrawHeader || _props.DrawGUI)
{
@ -122,13 +121,8 @@ namespace TriInspector.Elements
{
GUILayout.BeginVertical();
var horizontal = _props.DrawHeader || _props.DrawGUI;
var previewOpts = horizontal
? new[] {GUILayout.Width(_props.previewWidth), GUILayout.ExpandHeight(true),}
: new[] {GUILayout.ExpandWidth(true), GUILayout.Height(_props.previewHeight),};
var previewRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, previewOpts);
var previewOpts = new[] {GUILayout.ExpandWidth(true), GUILayout.Height(_props.previewHeight),};
var previewRect = EditorGUILayout.GetControlRect(false, _props.previewHeight, previewOpts);
previewRect.width = Mathf.Max(previewRect.width, 10);
previewRect.height = Mathf.Max(previewRect.height, 10);
@ -143,7 +137,7 @@ namespace TriInspector.Elements
GUILayout.EndVertical();
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
lastEditorRect = GUILayoutUtility.GetLastRect();
GUILayout.EndArea();
}

View File

@ -10,7 +10,6 @@ namespace TriInspector
{
public InlineEditorModes Mode { get; set; } = InlineEditorModes.GUIOnly;
public float PreviewWidth { get; set; } = 100;
public float PreviewHeight { get; set; } = 50;
public InlineEditorAttribute()