Skip to content

Commit 7497490

Browse files
committed
Update documentation
1 parent 6200354 commit 7497490

5 files changed

Lines changed: 116 additions & 25 deletions

File tree

Assets/Editor Toolbox/README.md

Lines changed: 112 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,24 @@ Unity 2018.x or newer
3636
- [Attributes & Drawers](#drawers)
3737
- [Regular Drawers](#regulardrawers)
3838
- [Toolbox Drawers](#toolboxdrawers)
39+
- [Toolbox Decorator Attributes](#toolboxdecorator)
40+
- [Toolbox Condition Attributes](#toolboxcondition)
41+
- [Toolbox Property (Self/List) Attributes](#toolboxproperty)
42+
- [Toolbox Special Attributes](#toolboxspecial)
43+
- [Toolbox Archetype Attributes](#toolboxarchetype)
44+
- [SerializeReference (ReferencePicker)](#toolboxserializereference)
45+
- [Toolbox Custom Editors](#toolboxeditors)
3946
- [Material Drawers](#materialdrawers)
4047
- [Serialized Types](#serialized-types)
4148
- [Editor Extensions](#editor-extensions)
4249
- [Hierarchy](#hierarchy)
4350
- [Project](#project)
4451
- [Toolbar](#toolbar)
4552
- [Utilities](#utilities)
46-
- [Editor Extras](#editor-extras)
4753

4854
## Settings
4955

50-
The most important file, it allows the user to manage all available features. Can be accessed from the Project Settings window (Edit/Project Settings.../Editor Toolbox) or directly inside the Project window. Make sure to have one valid settings file per project.
56+
The most important file, allows the user to manage all available features. Can be accessed from the Project Settings window (Edit/Project Settings.../Editor Toolbox) or directly inside the Project window. Make sure to have one valid settings file per project.
5157

5258
Available features are divided into three groups:
5359
- Hierarchy
@@ -56,6 +62,9 @@ Available features are divided into three groups:
5662

5763
Each module is described in its respective section.
5864

65+
If you want to keep your custom settings between UET versions, create your own settings file:
66+
```Create/Editor Toolbox/Settings```
67+
5968
## Attributes & Drawers <a name="drawers"></a>
6069

6170
### Regular Drawers <a name="regulardrawers"></a>
@@ -81,17 +90,6 @@ public float var1 = 80.0f;
8190
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/progressbar1.png)\
8291
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/progressbar2.png)
8392

84-
#### NewLabelAttribute
85-
86-
```csharp
87-
[NewLabel("Custom Label", "Element")]
88-
public int[] vars1 = new int[3];
89-
[NewLabel("Custom Label")]
90-
public float var2 = 25.4f;
91-
```
92-
93-
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/newlabel.png)
94-
9593
#### MinMaxSliderAttribute
9694

9795
```csharp
@@ -112,10 +110,6 @@ public Component var2;
112110

113111
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/assetpreview.png)
114112

115-
#### HideLabelAttribute
116-
117-
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/hidelabel.png)
118-
119113
#### SuffixAttribute
120114

121115
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/suffix.png)
@@ -255,7 +249,7 @@ Examples **'How to'** create custom ToolboxDrawers you can find [HERE](https://g
255249

256250
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/inspector.png)
257251

258-
#### ToolboxDecoratorAttributes
252+
#### Toolbox Decorator Attributes <a name="toolboxdecorator"></a>
259253

260254
Display/create something before and after property in the desired order (using Order property).
261255
In fact **ToolboxDecoratorDrawers** are like extended version of built-in **DecoratorDrawers**.
@@ -337,7 +331,7 @@ public int var1;
337331

338332
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/button.png)
339333

340-
#### ToolboxConditionAttributes
334+
#### Toolbox Condition Attributes <a name="toolboxcondition"></a>
341335

342336
Enable/disable or show/hide properties using custom conditions. You can use them together with any other type of drawer.
343337
Every ToolboxConditionDrawer supports boolean, int, string, UnityEngine.Object and enum types and works even with array/list properties.
@@ -388,7 +382,9 @@ public int[] vars1 = new [] { 1, 2, 3, 4 };
388382
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/enableif1.png)\
389383
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/enableif2.png)
390384

391-
#### InLineEditorAttribute
385+
#### Toolbox Property Attributes <a name="toolboxproperty"></a>
386+
387+
##### InLineEditorAttribute
392388

393389
This attribute gives a great possibility to extend all reference-related (UnityEngine.Object) fields.
394390
Using it you are able to 'inline' Editors for: components, ScriptableObjects, Materials, Renderers, MeshFilters, Textures, AudioClips, etc.
@@ -409,7 +405,7 @@ public Material var1;
409405
```
410406
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/inlined1.png)
411407

412-
#### Reorderable List
408+
##### Reorderable List
413409

414410
Custom implementation of standard ReorderableList (UnityEditorInternal). Usable as an attribute in serialized fields or a single object in custom Editors.
415411

@@ -448,7 +444,7 @@ private int GetValue()
448444
}
449445
```
450446

451-
#### ScrollableItemsAttribute
447+
##### ScrollableItemsAttribute
452448

453449
It's a perfect solution to inspect large arrays/lists and optimize displaying them within the Inspector window.
454450

@@ -459,7 +455,7 @@ public GameObject[] largeArray = new GameObject[19];
459455

460456
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/scrollableitems.png)
461457

462-
#### Other ToolboxProperty attributes
458+
##### Other ToolboxProperty attributes
463459

464460
```csharp
465461
[IgnoreParent]
@@ -474,7 +470,23 @@ public float minValue;
474470
public float MaxValue => 15.0f;
475471
```
476472

477-
#### ToolboxArchetypeAttributes
473+
#### Toolbox Special Attributes <a name="toolboxspecial"></a>
474+
475+
Attributes handled internally by the ToolboxEditor. You can combine them with any other attributes.
476+
477+
```csharp
478+
[NewLabel("Custom Label")]
479+
public float var1 = 25.4f;
480+
```
481+
482+
```csharp
483+
[HideLabel]
484+
public float var1;
485+
```
486+
487+
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/hidelabel.png)
488+
489+
#### Toolbox Archetype Attributes <a name="toolboxarchetype"></a>
478490

479491
Using this attribute you are able to implement custom patterns of frequently grouped **ToolboxAttributes**.
480492

@@ -513,6 +525,81 @@ public int var1;
513525

514526
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/title.png)
515527

528+
#### SerializeReference (ReferencePicker) <a name="toolboxserializereference></a>
529+
530+
You can draw properties marked with the [SerializeReference] attribute with an additional type picker that allows you to manipulate what managed type will be serialized.
531+
532+
```csharp
533+
[SerializeReference, ReferencePicker]
534+
public Interface1 var1;
535+
[SerializeReference, ReferencePicker]
536+
public ClassWithInterfaceBase var2;
537+
538+
public interface Interface1 { }
539+
540+
[Serializable]
541+
public struct Struct : Interface1
542+
{
543+
public bool var1;
544+
public bool var2;
545+
}
546+
547+
public abstract class ClassWithInterfaceBase : Interface1 { }
548+
549+
[Serializable]
550+
public class ClassWithInterface1 : ClassWithInterfaceBase
551+
{
552+
public GameObject go;
553+
}
554+
555+
[Serializable]
556+
public class ClassWithInterface2 : ClassWithInterfaceBase
557+
{
558+
[LeftToggle]
559+
public bool var1;
560+
}
561+
562+
[Serializable]
563+
public class ClassWithInterface3 : ClassWithInterfaceBase
564+
{
565+
public int var1;
566+
}
567+
```
568+
569+
![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/referencepicker.png)
570+
571+
#### Custom Editors <a name="toolboxeditors"></a>
572+
573+
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.
574+
575+
```csharp
576+
using UnityEditor;
577+
using UnityEngine;
578+
#if UNITY_2019_1_OR_NEWER
579+
using UnityEditor.UIElements;
580+
using UnityEngine.UIElements;
581+
#endif
582+
using Toolbox.Editor;
583+
584+
[CustomEditor(typeof(SampleBehaviour))]
585+
public class SampleEditor : ToolboxEditor
586+
{
587+
private void OnEnable()
588+
{ }
589+
590+
private void OnDisable()
591+
{ }
592+
593+
public override void DrawCustomInspector()
594+
{
595+
base.DrawCustomInspector();
596+
597+
//for custom properties:
598+
// - ToolboxEditorGui.DrawToolboxProperty(serializedObject.FindProperty("myProperty"));
599+
}
600+
}
601+
```
602+
516603
### Material Drawers <a name="materialdrawers"></a>
517604

518605
```
@@ -548,7 +635,7 @@ _HideIfExample ("Range", Range(0, 1)) = 0.75
548635
Allows to serialize Types and pick them through a dedicated picker.
549636

550637
```csharp
551-
[ClassExtends(typeof(Collider), Grouping = ClassGrouping.None, AddTextSearchField = false)] //or [ClassImplements(typeof(interface))] for interfaces
638+
[TypeConstraint(typeof(Collider), AllowAbstract = false, AllowObsolete = false, TypeSettings = TypeSettings.Class, TypeGrouping = TypeGrouping.None)]
552639
public SerializedType var1;
553640

554641
public void Usage()

Assets/Examples/Scenes/SampleScene.unity

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,8 @@ MonoBehaviour:
965965
typeReference: UnityEngine.UI.RawImage, UnityEngine.UI
966966
type3:
967967
typeReference:
968+
type4:
969+
typeReference: UnityEngine.BoxCollider, UnityEngine.PhysicsModule
968970
scene1:
969971
sceneReference: {fileID: 102900000, guid: f11034f4657f51a47aac14f26410c500, type: 3}
970972
sceneName: SampleScene

Assets/Examples/Scripts/SampleBehaviour5.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class SampleBehaviour5 : MonoBehaviour
1313
public SerializedType type2;
1414
[TypeConstraint(typeof(IMaskable), AddTextSearchField = true, TypeSettings = TypeSettings.Interface)]
1515
public SerializedType type3;
16+
[TypeConstraint(typeof(Collider), AllowAbstract = false, AllowObsolete = false, TypeSettings = TypeSettings.Class, TypeGrouping = TypeGrouping.None)]
17+
public SerializedType type4;
1618

1719
[Label("Serialized Scene", skinStyle: SkinStyle.Box)]
1820

Docs/referencepicker.png

15.3 KB
Loading

Docs/utils.png

-3.25 KB
Loading

0 commit comments

Comments
 (0)