Provided here Toolbox is focused on additional Editor features. The main reason for its creation was to improve the useability and clarity of Unity Editor's key functionalities. The most time-consuming part was the preparation of custom property drawers and whole proprietary, layout-based drawers system. It allows programmers to create a readable and useful component editor only by using attributes. Next crucial thing is fast and clear access to the data from particular Game Objects placed in the Scene. Therefore it was decided to extend the hierarchy with additional information. Last main module of presented Toolbox is focused on the Project window. The provided extension allows user to customize folder icons. Additionally, this repository contains many useful scripts, classes, and functions for Editor extensions development. It's worth to mention this code was written to be as flexible and optimized as possible. More information about the main features is described in the following sections.
Unity 2018.x or newer
- Copy and paste
Editor Toolbox
directory into your project (basically intoAsset
directory or somewhere deeper) - Open Edit/Project Settings/Editor Toolbox window
- If Toolbox Editor Settings is not available, press "Try to find the settings file" button or create new
- Manage settings in your way
- Enable/disable Hierarchy overlay
- Enable/disable Project icons or/and assign own directories
- Enable/disable Toolbox drawers or/and assign custom drawers
The most important file, it allows user to manage all available features. Can be accessed within the Project Settings window (Edit/Project Settings.../Editor Toolbox) or directly from the Project window. Make sure to have one valid settings file within a project.
Available features are divided into three sections:
- Hierarchy
- Project
- Inspector
Each module is described in details within the associated section.
Drawers based on build-in classes PropertyDrawer/DecoratorDrawer and associated PropertyAttribute.
Editor Toolbox/Scripts/Attributes/
Editor Toolbox/Editor/Drawers/
[Help("You can provide more information in HelpBoxes.", order = 100)]
public int var1;
[TagSelector]
public string var1;
[ProgressBar(minValue:0.0f, maxValue:100.0f)]
public float var1 = 36.0f;
public bool toggle;
[ConditionalHide(nameof(toggle), true)]
public float var1;
public bool toggle;
[ConditionalDisable(nameof(toggle), true)]
public float var1;
[ClassExtends(typeof(UnityEngine.Object))]
public SerializedType type1;
[ClassImplements(typeof(System.Collections.ICollection))]
public SerializedType type2;
[ReadOnlyField]
public int var1;
[System.Flags]
public enum FlagExample
{
Nothing = 0,
Flag1 = 1,
Flag2 = 2,
Flag3 = 4,
Everything = ~0
}
[EnumFlag]
public FlagExample enumFlag = FlagExample.Flag1 | FlagExample.Flag2;
[EnumFlag(EnumStyle.Button)]
public FlagExample enumFlag = FlagExample.Flag1 | FlagExample.Flag2 | FlagExample.Flag4 | FlagExample.Flag8;
//NOTE1: to broadcast messages in Edit mode desired component has to have [ExecuteAlways] or [ExecuteInEditMode] attribute
//NOTE2: Unity broadcasting will invoke all matching methods on this behaviour
[BroadcastButton(nameof(MyMethod), "Click me to broadcast message", ButtonActivityType.OnEditMode, order = 100)]
public int var1;
private void MyMethod()
{
Debug.Log("MyMethod is invoked");
}
private readonly int[] presetValues = new[] { 1, 2, 3, 4, 5 };
[Preset("presetValues")]
public int presetTarget;
[SearchableEnum]
public KeyCode enumSearch;
[Clamp(minValue = 1.5f, maxValue = 11.3f)]
public double var1;
Drawers based on classes inheriting from ToolboxDrawer and associated ToolboxAttribute. A quite powerful custom system that allows you to create really flexible drawers. You can use them without limitations (they work with sub-classes and as array children). Every ToolboxDrawer is layout-based. For proper work they need at least one settings file located in your project. You can find predefined one here - Editor Toolbox/EditorSettings.asset
.
Editor Toolbox/Scripts/Attributes/ToolboxAttributes
Editor Toolbox/Editor/Drawers/ToolboxDrawers
Display/create something before and after property in the desired order(using Order property).
In fact ToolboxDecoratorDrawers are like extended version of built-in DecoratorDrawers.
Unfortunately, standard decorators won't always work with ToolboxDrawers so try to use this replacement instead.
[BeginGroup("Group1")]
public int var1;
public int var2;
public int var3;
[EndGroup]
public int var4;
[BeginHorizontal]
public int var1;
public int var2;
[EndHorizontal]
public int var3;
[BeginIndent]
public int var1;
public int var2;
public int var3;
[EndIndent]
public int var4;
[SpaceArea(spaceBefore = 10.0f, spaceAfter = 5.0f, Order = 1)]
public int var1;
[HeaderArea("My Custom Header")]
public int var1;
[Highlight(0, 1, 0)]
public int var1;
[ReorderableList(ListStyle.Round)]
public List<string> standardStyleList;
[InLineEditor]
public Transform var1;
[InLineEditor]
public AudioClip var1;
[InLineEditor(drawHeader:false, drawPreview:true)]
public Material var1;
Hides any property.
Same like standard PropertyDrawer for ConditionalHideAttribute but works with Enum types and arrays/lists.
Can be used additionally to any PropertyDrawer or ToolboxPropertyDrawer.
Disables any property.
Can be used additionally to any PropertyDrawer or ToolboxPropertyDrawer.
Same as standard PropertyDrawer for ConditionalDisableAttribute but works with Enum types and arrays/lists.
Can be used additionally to any PropertyDrawer or ToolboxPropertyDrawer.
[Disable, ReorderableList]
public int[] vars1 = new [] { 1, 2, 3, 4 };
Custom implementation of standard ReorderableList(UnityEditorInternal). Useable as an attribute in inspector fields or a single object in custom editors.
Editor Toolbox/Editor/Internal/ReorderableList.cs
var list = new ReorderableList(SerializedProperty property, string elementLabel, bool draggable, bool hasHeader, bool fixedSize);
[ReorderableList(ListStyle.Lined, "Item")]
public List<int> linedStyleList;
[ReorderableList(ListStyle.Round)]
public List<string> standardStyleList;
[ReorderableList(ListStyle.Boxed, fixedSize: true)]
public GameObject[] boxedStyleList = new GameObject[4];
Enable custom hierarchy overlay in ToolboxEditorSettings. Basically it provides more data about particular GameObjects directly within the Hierarchy window.
Each row contains:
- Layer
- Tag
- Toggle to enable/disable GameObject
- Icon
Editor Toolbox/Editor/ToolboxEditorHierarchy.cs
Set custom folder icons in ToolboxEditorSettings.
Properties that can be edited include:
- XY position and scale of the large icon
- XY position and scale of the small icon
- Path to directory or name (depends on picked item type)
- Optional tooltip
- Large icon
- Small icon
Editor Toolbox/Editor/ToolboxEditorProject.cs
Editor Toolbox/Editor/ToolboxEditorToolbar.cs
Check Examples for more details.
Examples/Editor/SampleToolbar.cs
using Toolbox.Editor;
[UnityEditor.InitializeOnLoad]
public static class MyEditorUtility
{
static MyEditorUtility()
{
ToolboxEditorToolbar.AddToolbarButton(new ToolbarButton(() => Debug.Log("1"), new GUIContent("1")));
ToolboxEditorToolbar.AddToolbarButton(new ToolbarButton(() => Debug.Log("2"), new GUIContent("2")));
ToolboxEditorToolbar.AddToolbarButton(new ToolbarButton(() => Debug.Log("3"), new GUIContent("3")));
ToolboxEditorToolbar.AddToolbarButton(new ToolbarButton(() => Debug.Log("4"), new GUIContent("4")));
ToolboxEditorToolbar.AddToolbarButton(new ToolbarButton(() => Debug.Log("5"), new GUIContent("5")));
}
}
Copy and paste all components from/to particular GameObject.
I decieded to move additional editors and tools to Gist.
Check it out HERE
Check it out HERE
Check it out HERE