Enable full editors by default

This commit is contained in:
VladV 2022-05-25 10:10:21 +03:00
parent fda4fe744e
commit 3c8ddb2723
6 changed files with 4 additions and 92 deletions

View File

@ -1,13 +0,0 @@
using UnityEditor;
using UnityEngine;
namespace TriInspector.Editors
{
#if TRI_INSPECTOR
[CanEditMultipleObjects]
[CustomEditor(typeof(MonoBehaviour), true, isFallback = true)]
internal sealed class MonoBehaviourEditor : TriEditor
{
}
#endif
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 1c8274dd1fc8462c81ee2518b617d0f4
timeCreated: 1638716636

View File

@ -1,13 +0,0 @@
using UnityEditor;
using UnityEngine;
namespace TriInspector.Editors
{
#if TRI_INSPECTOR
[CanEditMultipleObjects]
[CustomEditor(typeof(ScriptableObject), true, isFallback = true)]
internal sealed class ScriptableObjectEditor : TriEditor
{
}
#endif
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 821b3e07ed6e47bfb89586d61fcaa8fc
timeCreated: 1638716639

View File

@ -1,6 +1,4 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEditor;
namespace TriInspector.Editors
{
@ -8,7 +6,6 @@ namespace TriInspector.Editors
{
private class Styles
{
public static readonly GUIContent Mode = new GUIContent("Tri Inspector Mode");
}
public TriSettingsProvider()
@ -22,64 +19,9 @@ namespace TriInspector.Editors
base.OnGUI(searchContext);
DrawModeButton();
EditorGUI.EndDisabledGroup();
}
private void DrawModeButton()
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(Styles.Mode);
var targetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
var isFull = HasScriptingDefine(targetGroup, "TRI_INSPECTOR");
var isCompact = !isFull;
if (isCompact != GUILayout.Toggle(isCompact, "Compact", EditorStyles.miniButtonLeft) && !isCompact)
{
UpdateScriptingDefine(targetGroup, toRemove: "TRI_INSPECTOR");
}
if (isFull != GUILayout.Toggle(isFull, "Full", EditorStyles.miniButtonRight) && !isFull)
{
UpdateScriptingDefine(targetGroup, toAdd: "TRI_INSPECTOR");
}
GUILayout.EndHorizontal();
}
private static bool HasScriptingDefine(BuildTargetGroup targetGroup, string define)
{
return PlayerSettings
.GetScriptingDefineSymbolsForGroup(targetGroup)
.Split(';')
.Contains(define);
}
private static void UpdateScriptingDefine(BuildTargetGroup targetGroup,
string toAdd = null, string toRemove = null)
{
var defines = PlayerSettings
.GetScriptingDefineSymbolsForGroup(targetGroup)
.Split(';')
.ToList();
if (toAdd != null && !defines.Contains(toAdd))
{
defines.Add(toAdd);
}
if (toRemove != null && defines.Contains(toRemove))
{
defines.Remove(toRemove);
}
var definesString = string.Join(";", defines);
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, definesString);
}
[SettingsProvider]
public static SettingsProvider CreateTriInspectorSettingsProvider()
{

View File

@ -5,7 +5,9 @@ using UnityEngine.Profiling;
namespace TriInspector
{
public abstract class TriEditor : Editor
[CanEditMultipleObjects]
[CustomEditor(typeof(Object), editorForChildClasses: true, isFallback = true)]
public class TriEditor : Editor
{
private static readonly Stack<Editor> EditorStack = new Stack<Editor>();