mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Moved editor recursion check to TriEditor class
This commit is contained in:
parent
65e75ea953
commit
ffb0e8f4c5
@ -78,43 +78,33 @@ namespace TriInspector.Elements
|
||||
}
|
||||
|
||||
var lastEditorRect = Rect.zero;
|
||||
var shouldDrawEditor = _property.IsExpanded && !_property.IsValueMixed;
|
||||
|
||||
if (TriGuiHelper.IsEditorTargetPushed((Object) _property.Value))
|
||||
if (_editor == null && shouldDrawEditor && _property.Value is Object obj && obj != null)
|
||||
{
|
||||
GUI.Label(position, "Recursive inline editors not supported");
|
||||
_editor = Editor.CreateEditor(obj);
|
||||
}
|
||||
|
||||
lastEditorRect.height = EditorGUIUtility.singleLineHeight;
|
||||
if (_editor != null && shouldDrawEditor)
|
||||
{
|
||||
Rect indentedEditorPosition;
|
||||
using (TriGuiHelper.PushIndentLevel())
|
||||
{
|
||||
indentedEditorPosition = EditorGUI.IndentedRect(_editorPosition);
|
||||
}
|
||||
|
||||
GUILayout.BeginArea(indentedEditorPosition);
|
||||
GUILayout.BeginVertical();
|
||||
_editor.OnInspectorGUI();
|
||||
GUILayout.EndVertical();
|
||||
lastEditorRect = GUILayoutUtility.GetLastRect();
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
else
|
||||
{
|
||||
var shouldDrawEditor = _property.IsExpanded && !_property.IsValueMixed;
|
||||
|
||||
if (_editor == null && shouldDrawEditor && _property.Value is Object obj && obj != null)
|
||||
if (_editor != null)
|
||||
{
|
||||
_editor = Editor.CreateEditor(obj);
|
||||
}
|
||||
|
||||
if (_editor != null && shouldDrawEditor)
|
||||
{
|
||||
Rect indentedEditorPosition;
|
||||
using (TriGuiHelper.PushIndentLevel())
|
||||
{
|
||||
indentedEditorPosition = EditorGUI.IndentedRect(_editorPosition);
|
||||
}
|
||||
|
||||
GUILayout.BeginArea(indentedEditorPosition);
|
||||
GUILayout.BeginVertical();
|
||||
_editor.OnInspectorGUI();
|
||||
GUILayout.EndVertical();
|
||||
lastEditorRect = GUILayoutUtility.GetLastRect();
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_editor != null)
|
||||
{
|
||||
Object.DestroyImmediate(_editor);
|
||||
}
|
||||
Object.DestroyImmediate(_editor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,19 +18,25 @@ namespace TriInspector
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (serializedObject.targetObjects.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (serializedObject.targetObject == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Script is missing", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TriGuiHelper.IsEditorTargetPushed(serializedObject.targetObject))
|
||||
{
|
||||
GUILayout.Label("Recursive inline editors not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_inspector == null)
|
||||
{
|
||||
if (serializedObject.targetObjects.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (serializedObject.targetObject == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Script is missing", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
_inspector = new TriPropertyTreeForSerializedObject(serializedObject);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user