Giter Club home page Giter Club logo

unity-editor-toolbox's Introduction

Unity Editor Toolbox

Introduction

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.

System Requirements

Unity 2018.x or newer

Installation

  • Copy and paste Editor Toolbox directory into your project (basically into Asset 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

Table Of Contents

Settings

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.

inspector

Available features are divided into three sections:

  • Hierarchy
  • Project
  • Inspector

Each module is described in details within the associated section.

Attributes

Native Drawers

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

 

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

 

HelpAttribute

[Help("You can provide more information in HelpBoxes.", order = 100)]
public int var1;

inspector

TagSelectorAttribute

[TagSelector]
public string var1;

inspector

SeparatorAttribute

inspector

ProgressBarAttribute

[ProgressBar(minValue:0.0f, maxValue:100.0f)]
public float var1 = 36.0f;

inspector inspector

NewLabelAttribute

inspector

MinMaxSliderAttribute

inspector

IndentAttribute

inspector

ConditionalHideAttribute

public bool toggle;
[ConditionalHide(nameof(toggle), true)]
public float var1;

inspector inspector

ConditionalDisableAttribute

public bool toggle;
[ConditionalDisable(nameof(toggle), true)]
public float var1;

inspector inspector

AssetPreviewAttribute

inspector

HideLabelAttribute

inspector

SuffixAttribute

inspector

TypeConstraintAttribute

[ClassExtends(typeof(UnityEngine.Object))]
public SerializedType type1;
[ClassImplements(typeof(System.Collections.ICollection))]
public SerializedType 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 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;

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

inspector

Reorderable List

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;

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. 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

inspector

Project

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

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

Copy and paste all components from/to particular GameObject.

inspector

Editor Extras

I decieded to move additional editors and tools to Gist.

Prefab/GameObject Painter

Check it out HERE


Field of View Generator

Check it out HERE

Grid Generator

Check it out HERE

unity-editor-toolbox's People

Contributors

arimger avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.