2022-05-04 03:15:08 -04:00
|
|
|
|
using System;
|
|
|
|
|
using TriInspector.Utilities;
|
2021-12-07 10:20:36 -05:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace TriInspector.Elements
|
|
|
|
|
{
|
|
|
|
|
internal class TriInlineGenericElement : TriPropertyCollectionBaseElement
|
|
|
|
|
{
|
2022-05-04 03:15:08 -04:00
|
|
|
|
private readonly Props _props;
|
2021-12-07 10:20:36 -05:00
|
|
|
|
private readonly TriProperty _property;
|
|
|
|
|
|
2022-05-04 03:15:08 -04:00
|
|
|
|
[Serializable]
|
|
|
|
|
public struct Props
|
|
|
|
|
{
|
|
|
|
|
public bool drawPrefixLabel;
|
|
|
|
|
public float labelWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TriInlineGenericElement(TriProperty property, Props props = default)
|
2021-12-07 10:20:36 -05:00
|
|
|
|
{
|
|
|
|
|
_property = property;
|
2022-05-04 03:15:08 -04:00
|
|
|
|
_props = props;
|
2021-12-07 10:20:36 -05:00
|
|
|
|
|
|
|
|
|
DeclareGroups(property.ValueType);
|
|
|
|
|
|
|
|
|
|
foreach (var childProperty in property.ChildrenProperties)
|
|
|
|
|
{
|
|
|
|
|
AddProperty(childProperty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect position)
|
|
|
|
|
{
|
2022-05-04 03:15:08 -04:00
|
|
|
|
if (_props.drawPrefixLabel)
|
2021-12-07 10:20:36 -05:00
|
|
|
|
{
|
|
|
|
|
var controlId = GUIUtility.GetControlID(FocusType.Passive);
|
|
|
|
|
position = EditorGUI.PrefixLabel(position, controlId, _property.DisplayNameContent);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 03:15:08 -04:00
|
|
|
|
using (TriGuiHelper.PushLabelWidth(_props.labelWidth))
|
2022-01-10 02:39:14 -05:00
|
|
|
|
{
|
|
|
|
|
base.OnGUI(position);
|
|
|
|
|
}
|
2021-12-07 10:20:36 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|