Skip to content

Commit 89c51b9

Browse files
committed
Conditional CustomEditor override
1 parent e1d3b74 commit 89c51b9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Assets/Editor Toolbox/Editor/ToolboxDefines.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
internal static class ToolboxDefines
44
{
55
internal const string defaultListsDefine = "TOOLBOX_FORCE_DEFAULT_LISTS";
6+
internal const string ignoreEditorDefine = "TOOLBOX_IGNORE_CUSTOM_EDITOR";
67
}
78
}

Assets/Editor Toolbox/Editor/ToolboxDrawerModule.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ internal static void UpdateDrawers(IToolboxInspectorSettings settings)
246246
//create all type-only-related drawers
247247
PrepareTargetTypeDrawers(settings);
248248

249-
HandleDefaultLists(settings.ForceDefaultLists);
249+
var useDefaultLists = settings.ForceDefaultLists;
250+
HandleDefaultLists(useDefaultLists);
251+
var ignoreCustomEditor = !settings.UseToolboxDrawers;
252+
HandleIgnoreEditor(ignoreCustomEditor);
250253
//log errors into console only once
251254
validationEnabled = false;
252255
}
@@ -301,6 +304,18 @@ internal static void HandleDefaultLists(bool value)
301304
}
302305
}
303306

307+
internal static void HandleIgnoreEditor(bool value)
308+
{
309+
if (value)
310+
{
311+
ScriptingUtility.AppendDefine(ToolboxDefines.ignoreEditorDefine);
312+
}
313+
else
314+
{
315+
ScriptingUtility.RemoveDefine(ToolboxDefines.ignoreEditorDefine);
316+
}
317+
}
318+
304319
internal static ToolboxDecoratorDrawerBase GetDecoratorDrawer<T>(T attribute) where T : ToolboxDecoratorAttribute
305320
{
306321
return GetDecoratorDrawer(attribute.GetType());

Assets/Editor Toolbox/Editor/ToolboxEditor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace Toolbox.Editor
99
/// <summary>
1010
/// Base Editor class for all Toolbox-related features.
1111
/// </summary>
12+
#if !TOOLBOX_IGNORE_CUSTOM_EDITOR
1213
[CustomEditor(typeof(Object), true, isFallback = true)]
14+
#endif
1315
[CanEditMultipleObjects]
1416
public class ToolboxEditor : Editor, IToolboxEditor
1517
{

0 commit comments

Comments
 (0)