Skip to content

Commit bee8979

Browse files
committed
Minor refactor changes & documentation update
1 parent 38abfb3 commit bee8979

File tree

6 files changed

+44
-15
lines changed

6 files changed

+44
-15
lines changed

Assets/Editor Toolbox/Editor/IToolboxEditor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ public interface IToolboxEditor
1010
void IgnoreProperty(SerializedProperty property);
1111
void IgnoreProperty(string propertyPath);
1212

13+
/// <summary>
14+
/// <see cref="Editor"/> instance associated to this Editor.
15+
/// </summary>
1316
Editor ContextEditor { get; }
17+
/// <summary>
18+
/// Dedicated "drawer" that is responsible for default drawing strategy for this <see cref="ToolboxEditor"/>.
19+
/// </summary>
1420
IToolboxEditorDrawer Drawer { get; }
1521
}
1622
}

Assets/Editor Toolbox/Editor/ToolboxEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void IgnoreProperty(string propertyPath)
4747

4848

4949
Editor IToolboxEditor.ContextEditor => this;
50+
/// <inheritdoc />
5051
public virtual IToolboxEditorDrawer Drawer { get; } = new ToolboxEditorDrawer();
5152

5253
#pragma warning disable 0067

Assets/Editor Toolbox/Editor/ToolboxEditorDrawer.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ public class ToolboxEditorDrawer : IToolboxEditorDrawer
1515
private readonly Action<SerializedProperty> toolboxDrawingAction;
1616
private readonly Action<SerializedProperty> defaultDrawingAction;
1717

18-
public ToolboxEditorDrawer() : this(ToolboxEditorGui.DrawToolboxProperty, ToolboxEditorGui.DrawNativeProperty)
18+
public ToolboxEditorDrawer()
19+
: this(ToolboxEditorGui.DrawToolboxProperty)
20+
{ }
21+
22+
public ToolboxEditorDrawer(Action<SerializedProperty> toolboxDrawingAction)
23+
: this(toolboxDrawingAction, ToolboxEditorGui.DrawNativeProperty)
1924
{ }
2025

2126
public ToolboxEditorDrawer(Action<SerializedProperty> toolboxDrawingAction, Action<SerializedProperty> defaultDrawingAction)
@@ -26,12 +31,10 @@ public ToolboxEditorDrawer(Action<SerializedProperty> toolboxDrawingAction, Acti
2631

2732
private void DrawProperty(SerializedProperty property, Action<SerializedProperty> drawingAction)
2833
{
29-
if (IsPropertyIgnored(property))
34+
if (!IsPropertyIgnored(property))
3035
{
31-
return;
36+
drawingAction(property);
3237
}
33-
34-
drawingAction(property);
3538
}
3639

3740
/// <inheritdoc />

Assets/Editor Toolbox/HOWTO.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ public class IntDrawer : ToolboxTargetTypeDrawer
179179

180180
## Custom Editor
181181

182+
If you want to create a custom **UnityEditor.Editor** for your components and still use Toolbox-related features be sure to inherit from the **Toolbox.Editor.ToolboxEditor** class.
183+
182184
```csharp
183185
using UnityEditor;
184186
using UnityEngine;
@@ -216,6 +218,17 @@ public class SampleEditor : ToolboxEditor
216218
}
217219
#endif
218220

221+
private static void DrawMyCustomProperty(SerializedProperty property)
222+
{
223+
EditorGUILayout.PropertyField(property);
224+
}
225+
226+
/// <summary>
227+
/// You can override this property with your custom IToolboxEditorDrawer implementation to override the default way how the Editor is drawn.
228+
/// Additionally, you can assign your custom method directly for the ToolboxEditorDrawer.
229+
/// </summary>
230+
public override IToolboxEditorDrawer Drawer { get; } = new ToolboxEditorDrawer(DrawMyCustomProperty);
231+
219232
private static class Style
220233
{
221234
internal static readonly GUIStyle labelStyle;

Assets/Editor Toolbox/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ public class ClassWithInterface3 : ClassWithInterfaceBase
603603
#### Custom Editors <a name="toolboxeditors"></a>
604604

605605
If you want to create a custom **UnityEditor.Editor** for your components and still use Toolbox-related features be sure to inherit from the **Toolbox.Editor.ToolboxEditor** class.
606+
More details (e.g. how to customize properties drawing) you can find in the [HOWTO](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Assets/Editor%20Toolbox/HOWTO.md) document.
606607
607608
```csharp
608609
using UnityEditor;
@@ -632,6 +633,10 @@ public class SampleEditor : ToolboxEditor
632633
}
633634
```
634635

636+
##### Custom Editor Implementation
637+
- **Toolbox.Editor.ToolboxEditor** - default class, override it if you want to implement a custom Editor for your components and ScriptableObjects
638+
- **Toolbox.Editor.ToolboxScriptedImporterEditor** - override it if you want to implement a custom Editor for your custom importers
639+
635640
### Material Drawers <a name="materialdrawers"></a>
636641

637642
```

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ Unity 2018.x or newer
2222

2323
- Install Editor Toolbox package:
2424
- 1 way: Find Unity Package Manager (Window/Package Manager) and add package using this git URL:
25-
26-
```
27-
https://github.com/arimger/Unity-Editor-Toolbox.git#upm
28-
```
29-
25+
```
26+
https://github.com/arimger/Unity-Editor-Toolbox.git#upm
27+
```
3028
- 2 way: Copy and paste `Assets/Editor Toolbox` directory into your project (Assets/...) + add dependencies
3129
- 3 way: Install via [OpenUPM registry](https://openupm.com):
32-
33-
```
34-
openupm add com.browar.editor-toolbox
35-
```
36-
30+
```
31+
openupm add com.browar.editor-toolbox
32+
```
3733
- Open Edit/Project Settings/Editor Toolbox window
3834
- If settings file is not found, press the "Refresh" button or create a new one
3935
- Manage settings in your way
@@ -607,6 +603,7 @@ public class ClassWithInterface3 : ClassWithInterfaceBase
607603
#### Custom Editors <a name="toolboxeditors"></a>
608604

609605
If you want to create a custom **UnityEditor.Editor** for your components and still use Toolbox-related features be sure to inherit from the **Toolbox.Editor.ToolboxEditor** class.
606+
More details (e.g. how to customize properties drawing) you can find in the [HOWTO](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Assets/Editor%20Toolbox/HOWTO.md) document.
610607
611608
```csharp
612609
using UnityEditor;
@@ -636,6 +633,10 @@ public class SampleEditor : ToolboxEditor
636633
}
637634
```
638635

636+
##### Custom Editor Implementation
637+
- **Toolbox.Editor.ToolboxEditor** - default class, override it if you want to implement a custom Editor for your components and ScriptableObjects
638+
- **Toolbox.Editor.ToolboxScriptedImporterEditor** - override it if you want to implement a custom Editor for your custom importers
639+
639640
### Material Drawers <a name="materialdrawers"></a>
640641

641642
```

0 commit comments

Comments
 (0)