Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Unity Editor拡張]Hierarchyのオブジェクト名の左側にオブジェクトの有効化/無効化のボタンを表示
using UnityEditor;
using UnityEngine;
//Hierarchyウィンドウのオブジェクトの名前の左側にActiveのチェックボタンを表示
public static class EDITOR_HierarchyTogles
{
private const int WIDTH = 16;
[InitializeOnLoadMethod]
private static void Main()
{
EditorApplication.hierarchyWindowItemOnGUI += OnGUI;
}
private static void OnGUI( int instanceID, Rect selectionRect )
{
var go = EditorUtility.InstanceIDToObject( instanceID ) as GameObject;
if ( go == null )
{
return;
}
var pos = selectionRect;
pos.x = 0;
pos.width = WIDTH;
var newActive = GUI.Toggle( pos, go.activeSelf, string.Empty );
if ( newActive == go.activeSelf )
{
return;
}
go.SetActive( newActive );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment