In short, I decided in one document to describe some ways of extending the editor, making it more convenient to work with it.
The publication covered the following points:
- Display icons and text above the object in the scene;
- Display text or icon in the Project window;
- Scripts templates created;
- Opening and creating a project through the context menu of the explorer;
- Adding subscribers to an event in the inspector.
I will warn you in advance that in order to shorten the code in some scripts, all fields are made public. In real projects, this is not worth doing.
')
Display icons and text above the object in the scene

The name of the object or icon can be displayed using the built-in editor:
Gizmo and Icon Display Controls .
The icon can also be displayed using the Gizmos.DrawIcon method. The icon file should be located in the Assets / Gizmos folder.
public class IconExample : MonoBehaviour { void OnDrawGizmos() { Gizmos.DrawIcon(transform.position, "Icon.png", true); } }
If you want to display your text, you can use the following code:
public static class GizmosUtils { public static void DrawText(GUISkin guiSkin, string text, Vector3 position, Color? color = null, int fontSize = 0, float yOffset = 0) { #if UNITY_EDITOR var prevSkin = GUI.skin; if (guiSkin == null) Debug.LogWarning("editor warning: guiSkin parameter is null"); else GUI.skin = guiSkin; GUIContent textContent = new GUIContent(text); GUIStyle style = (guiSkin != null) ? new GUIStyle(guiSkin.GetStyle("Label")) : new GUIStyle(); if (color != null) style.normal.textColor = (Color)color; if (fontSize > 0) style.fontSize = fontSize; Vector2 textSize = style.CalcSize(textContent); Vector3 screenPoint = Camera.current.WorldToScreenPoint(position); if (screenPoint.z > 0) // , , { var worldPosition = Camera.current.ScreenToWorldPoint(new Vector3(screenPoint.x - textSize.x * 0.5f, screenPoint.y + textSize.y * 0.5f + yOffset, screenPoint.z)); UnityEditor.Handles.Label(worldPosition, textContent, style); } GUI.skin = prevSkin; #endif } }
public class GizmosTextExample : MonoBehaviour { public float yOffset = 16; public Color textColor = Color.cyan; public int fontSize = 12; private void OnDrawGizmos() { GizmosUtils.DrawText(GUI.skin, "Custom text", transform.position, textColor, fontSize, yOffset); } }
Display text or icon in the Project window

To do this, use the delegate EditorApplication.projectWindowItemOnGUI.
Below is an example of a slightly edited code found at the link:
Extending the editor: Project window .
[InitializeOnLoad] internal class CustomProjectWindow { static readonly Color labelColor = new Color(0.75f, 0.75f, 0.75f, 1.0f); static CustomProjectWindow() { EditorApplication.projectWindowItemOnGUI += OnProjectWindowGUI; } static void OnProjectWindowGUI(string pGUID, Rect pDrawingRect) { string assetpath = AssetDatabase.GUIDToAssetPath(pGUID); string extension = Path.GetExtension(assetpath); bool icons = pDrawingRect.height > 20; if (icons || assetpath.Length == 0) return; GUIStyle labelStyle = new GUIStyle(EditorStyles.label); Vector2 labelSize = labelStyle.CalcSize(new GUIContent(extension)); Rect newRect = pDrawingRect; newRect.width += pDrawingRect.x; newRect.x = newRect.width - labelSize.x - 4; Color prevGuiColor = GUI.color; GUI.color = labelColor; GUI.Label(newRect, extension, labelStyle); GUI.color = prevGuiColor; } }
Display text or icon in the Hierarchy window
Here I, perhaps, just leave a link to the article, in which there is already a good example:
“Restoring order in the Hierarchy View” .
Created Script Templates

When creating a new script in the Project window, you can select one of the existing script templates for it.
If you want to create a new script in it, it was already written some specific code, then you can edit these templates in advance, or create your own.
Templates are usually located in the following folders:
Windows: \ Program Files \ Unity \ Editor \ Data \ Resources \ ScriptTemplates
OS X: /Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates
I will describe the parameters in the template name "81-C # Script-NewBehaviourScript.cs":
"81" - the ordinal number of the template in the context menu;
"C # Script" - the display name in the context menu;
"NewBehaviourScript" is the default name of the created script.
Opening and creating a project through the context menu of Explorer

In Windows Explorer, you can add items to create or open an existing Unity3D project.
The finished registry files can be downloaded from the link (Tip # 63 and Tip # 71):
Tip of the dayAdding subscribers to an event in the inspector

A bit off topic, but I would like to describe a rather useful innovation.
In Unity 4.6, the inspector finally added the ability to assign subscribers to an event. Now you can transfer objects to the list of subscribers and select the methods that we want to execute when we call this event.
To do this, it is enough to declare an event in the script with the UnityEvent type or its successor.
An example of code that creates objects after a specified period of time:
public class InvokeRepeating : MonoBehaviour { public UnityEvent onInvoke; public float repeatTime = 3f; public float startTime = 1f; void Start() { InvokeRepeating("Execute", startTime, repeatTime); } void Execute() { onInvoke.Invoke(); } }
public class CreateObject : MonoBehaviour { public Transform Prefab; public void Execute() { Instantiate(Prefab, transform.position, transform.rotation); } }
Farewell words
That, in general, is all that I wanted to write. I hope this publication will be useful for you.