Skip to content

Commit

Permalink
Conditional CustomEditor override
Browse files Browse the repository at this point in the history
  • Loading branch information
arimger committed Sep 8, 2024
1 parent e1d3b74 commit 89c51b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions Assets/Editor Toolbox/Editor/ToolboxDefines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
internal static class ToolboxDefines
{
internal const string defaultListsDefine = "TOOLBOX_FORCE_DEFAULT_LISTS";
internal const string ignoreEditorDefine = "TOOLBOX_IGNORE_CUSTOM_EDITOR";
}
}
17 changes: 16 additions & 1 deletion Assets/Editor Toolbox/Editor/ToolboxDrawerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ internal static void UpdateDrawers(IToolboxInspectorSettings settings)
//create all type-only-related drawers
PrepareTargetTypeDrawers(settings);

HandleDefaultLists(settings.ForceDefaultLists);
var useDefaultLists = settings.ForceDefaultLists;
HandleDefaultLists(useDefaultLists);
var ignoreCustomEditor = !settings.UseToolboxDrawers;
HandleIgnoreEditor(ignoreCustomEditor);
//log errors into console only once
validationEnabled = false;
}
Expand Down Expand Up @@ -301,6 +304,18 @@ internal static void HandleDefaultLists(bool value)
}
}

internal static void HandleIgnoreEditor(bool value)
{
if (value)
{
ScriptingUtility.AppendDefine(ToolboxDefines.ignoreEditorDefine);
}
else
{
ScriptingUtility.RemoveDefine(ToolboxDefines.ignoreEditorDefine);
}
}

internal static ToolboxDecoratorDrawerBase GetDecoratorDrawer<T>(T attribute) where T : ToolboxDecoratorAttribute
{
return GetDecoratorDrawer(attribute.GetType());
Expand Down
2 changes: 2 additions & 0 deletions Assets/Editor Toolbox/Editor/ToolboxEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ namespace Toolbox.Editor
/// <summary>
/// Base Editor class for all Toolbox-related features.
/// </summary>
#if !TOOLBOX_IGNORE_CUSTOM_EDITOR
[CustomEditor(typeof(Object), true, isFallback = true)]
#endif
[CanEditMultipleObjects]
public class ToolboxEditor : Editor, IToolboxEditor
{
Expand Down

0 comments on commit 89c51b9

Please sign in to comment.