Remove default inspector

This commit is contained in:
VladV 2022-01-05 16:11:51 +03:00
parent b84d4f6060
commit 7126386a43

View File

@ -1,13 +1,11 @@
using TriInspector.Utilities;
using UnityEditor;
using UnityEngine;
using UnityEngine.Profiling;
namespace TriInspector
{
public abstract class TriEditor : Editor
{
private bool _drawDefaultInspector;
private TriPropertyTree _inspector;
private void OnEnable()
@ -33,64 +31,29 @@ namespace TriInspector
serializedObject.UpdateIfRequiredOrScript();
DrawInspectorModeHeader();
if (_drawDefaultInspector)
Profiler.BeginSample("TriInspector.Update()");
try
{
DrawDefaultInspector();
_inspector.Update();
}
else
finally
{
Profiler.BeginSample("TriInspector.Update()");
try
{
_inspector.Update();
}
finally
{
Profiler.EndSample();
}
Profiler.EndSample();
}
TriGuiHelper.PushEditor(this);
Profiler.BeginSample("TriInspector.DoLayout()");
try
{
_inspector.DoLayout();
}
finally
{
Profiler.EndSample();
TriGuiHelper.PopEditor(this);
}
TriGuiHelper.PushEditor(this);
Profiler.BeginSample("TriInspector.DoLayout()");
try
{
_inspector.DoLayout();
}
finally
{
Profiler.EndSample();
TriGuiHelper.PopEditor(this);
}
serializedObject.ApplyModifiedProperties();
}
private void DrawInspectorModeHeader()
{
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Toggle(!_drawDefaultInspector, "Tri Inspector", EditorStyles.miniButtonLeft))
{
_drawDefaultInspector = false;
}
if (GUILayout.Toggle(_drawDefaultInspector, "Default Inspector", EditorStyles.miniButtonRight))
{
_drawDefaultInspector = true;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(5);
var rect = EditorGUILayout.GetControlRect(false, 1);
EditorGUI.DrawRect(rect, Color.gray);
GUILayout.Space(10);
}
}
}