Fix no targets exception in TriEditor

This commit is contained in:
VladV 2022-05-18 21:29:06 +03:00
parent fc4da39d75
commit 89aff42a3c

View File

@ -11,19 +11,16 @@ namespace TriInspector
private TriPropertyTree _inspector; private TriPropertyTree _inspector;
private TriEditorMode _editorMode;
private void OnEnable() private void OnEnable()
{ {
var mode = TriEditorMode.None; _editorMode = TriEditorMode.None;
var isInlineEditor = EditorStack.Count > 0; var isInlineEditor = EditorStack.Count > 0;
if (isInlineEditor) if (isInlineEditor)
{ {
mode |= TriEditorMode.InlineEditor; _editorMode |= TriEditorMode.InlineEditor;
}
if (serializedObject.targetObject != null)
{
_inspector = TriPropertyTree.Create(serializedObject, mode);
} }
} }
@ -37,10 +34,14 @@ namespace TriInspector
{ {
if (_inspector == null) if (_inspector == null)
{ {
DrawDefaultInspector(); if (serializedObject.targetObjects.Length == 0)
{
return; return;
} }
_inspector = TriPropertyTree.Create(serializedObject, _editorMode);
}
serializedObject.UpdateIfRequiredOrScript(); serializedObject.UpdateIfRequiredOrScript();
Profiler.BeginSample("TriInspector.Update()"); Profiler.BeginSample("TriInspector.Update()");