Unity Editor Toolbox by arimger - 1

ToolsExtensions

Tools, custom attributes, drawers and extensions for Unity Editor.

Unity 2018.4.10f1MIT LicenseUpdated 8 hours agoCreated on August 11th, 2019
Go to source

Unity Editor Toolbox

Introduction

TODO

System Requirements

Unity 2018.x or newer

Instalation

  • Copy and paste Editor Toolbox directory into your project (basically into Asset directory or somewhere deeper)
  • Find ToolboxEditorSettings file (predefined one is created as Editor Toolbox/EditorSettings.asset)
    • Enable/disable Hierarchy overlay
    • Enable/disable Project icons or/and assign own directories
    • Enable/disable Toolbox drawers or/and assign custom drawers
  • Press “Apply” button

Table Of Contents

Attributes

Native Drawers

Drawers based on build-in classes PropertyDrawer/DecoratorDrawer and associated PropertyAttribute.

 

Editor Toolbox/Scripts/Attributes/
Editor Toolbox/Editor/Drawers/

 

HelpAttribute

inspector

TagSelectorAttribute

inspector

SeparatorAttribute

inspector

ProgressBarAttribute

inspector inspector

NewLabelAttribute

inspector

MinMaxSliderAttribute

inspector

IndentAttribute

inspector

ConditionalHideAttribute

inspector inspector

ConditionalDisableAttribute

inspector inspector

AssetPreviewAttribute

inspector

HideLabelAttribute

inspector

SuffixAttribute

inspector

TypeConstraintAttribute

[ClassExtends(typeof(UnityEngine.Object))]
public SerializedTypeReference type1;
[ClassImplements(typeof(System.Collections.ICollection))]
public SerializedTypeReference type2;

inspector

ReadOnlyFieldAttribute

[ReadOnlyField]
public int var1;

inspector

BoxedHeaderAttribute

inspector

BoxedToggleAttribute

inspector

EnumFlagAttribute

[System.Flags]
public enum FlagExample
{
    Nothing = 0,
    Flag1 = 1,
    Flag2 = 2,
    Flag3 = 4,
    Everything = ~0
}

[EnumFlag]
public FlagExample enumFlag = FlagExample.Flag1 | FlagExample.Flag2;

inspector

[EnumFlag(EnumStyle.Button)]
public FlagExample enumFlag = FlagExample.Flag1 | FlagExample.Flag2 | FlagExample.Flag4 | FlagExample.Flag8;

inspector

NotNullAttribute

inspector inspector

RandomAttribute

inspector

DirectoryAttribute

inspector inspector

BroadcastButtonAttribute

//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");
}

inspector

InstanceButtonAttribute

inspector

SceneNameAttribute

inspector inspector

PresetAttribute

private readonly int[] presetValues = new[] { 1, 2, 3, 4, 5 };

[Preset("presetValues")]
public int presetTarget;

inspector

SearchableEnumAttribute

[SearchableEnum]
public KeyCode enumSearch;

inspector

ClampAttribute

[Clamp(minValue = 1.5f, maxValue = 11.3f)]
public double var1;

Toolbox Drawers

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

 

inspector

ToolboxDecoratorAttributes

Display/create something before and after property in 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;

ReorderableListAttribute

[ReorderableList(ListStyle.Round)]
public List<string> standardStyleList;

inspector

InLineEditorAttribute

[InLineEditor]
public Transform var1;

inspector

[InLineEditor]
public AudioClip var1;

inspector

[InLineEditor(drawHeader:false, drawPreview:true)]
public Material var1;

inspector

HideAttribute

Hides any property.

HideIfAttribute

Same like standard PropertyDrawer for ConditionalHideAttribute but works with Enum types and arrays/lists.
Can be used additionally to any PropertyDrawer or ToolboxPropertyDrawer.

DisableAttribute

Disables any property.
Can be used additionally to any PropertyDrawer or ToolboxPropertyDrawer.

DisableIfAttribute

Same like 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 };

inspector

Reorderable List

Editor Toolbox/Editor/Internal/ReorderableList.cs

Custom implementation of standard ReorderableList(UnityEditorInternal). Useable as attribute in inspector fields or single object in custom editors.

var list = new ReorderableList(SerializedProperty property, string elementLabel, bool draggable, bool hasHeader, bool fixedSize);
[ReorderableList(ListStyle.Lined, "Item")]
public List<int> linedStyleList;

inspector

[ReorderableList(ListStyle.Round)]
public List<string> standardStyleList;

inspector

[ReorderableList(ListStyle.Boxed, fixedSize: true)]
public GameObject[] boxedStyleList = new GameObject[4];

inspector

Editor Extensions

Hierarchy

Enable custom hierarchy overlay in ToolboxEditorSettings.

Editor Toolbox/Editor/ToolboxEditorHierarchy.cs

inspector

Project

Set custom folder icons in ToolboxEditorSettings.

Editor Toolbox/Editor/ToolboxEditorProject.cs

inspector

inspector

Toolbar

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")));
    }
}

inspector

Utilities

TODO

Editor Extras

I decieded to move additional editors and tools to Gist.

Terrain Editor

Check it out HERE


Field of View Generator

Check it out HERE

Grid Generator

Check it out HERE

Show all projects by arimger