Support Foldout SerializedProperty

This commit is contained in:
Freddie 2023-09-05 11:05:49 +08:00 committed by VladV
parent bad2a1943a
commit 40631a2bc5

View File

@ -8,7 +8,16 @@ namespace TriInspector.Utilities
public static void Foldout(Rect rect, TriProperty property)
{
var content = property.DisplayNameContent;
property.IsExpanded = EditorGUI.Foldout(rect, property.IsExpanded, content, true);
if (property.TryGetSerializedProperty(out var serializedProperty))
{
EditorGUI.BeginProperty(rect, content, serializedProperty);
property.IsExpanded = EditorGUI.Foldout(rect, property.IsExpanded, content, true);
EditorGUI.EndProperty();
}
else
{
property.IsExpanded = EditorGUI.Foldout(rect, property.IsExpanded, content, true);
}
}
public static void DrawBox(Rect position, GUIStyle style,