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 TriEditorMode _editorMode;
private void OnEnable()
{
var mode = TriEditorMode.None;
_editorMode = TriEditorMode.None;
var isInlineEditor = EditorStack.Count > 0;
if (isInlineEditor)
{
mode |= TriEditorMode.InlineEditor;
}
if (serializedObject.targetObject != null)
{
_inspector = TriPropertyTree.Create(serializedObject, mode);
_editorMode |= TriEditorMode.InlineEditor;
}
}
@ -37,8 +34,12 @@ namespace TriInspector
{
if (_inspector == null)
{
DrawDefaultInspector();
return;
if (serializedObject.targetObjects.Length == 0)
{
return;
}
_inspector = TriPropertyTree.Create(serializedObject, _editorMode);
}
serializedObject.UpdateIfRequiredOrScript();