Contenu connexe
Similaire à Unity エディタ拡張 (20)
Unity エディタ拡張
- 26. /68
Hierarchyビューの拡張
26
using UnityEditor;
using UnityEngine;
public static class ExampleClass
{
[InitializeOnLoadMethod]
static void Example()
{
EditorApplication.hierarchyWindowItemOnGUI += OnGUI;
}
static void OnGUI( int instanceID, Rect selectionRect )
{
var obj = EditorUtility.InstanceIDToObject( instanceID );
var go = obj as GameObject;
if ( go == null )
{
return;
}
var pos = selectionRect;
pos.x = pos.xMax - 16;
pos.width = 16;
var newActive = GUI.Toggle( pos, go.activeSelf, string.Empty );
go.SetActive( newActive );
}
}
- 43. /68
Projectビューの拡張
43
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public class ExampleClass
{
[InitializeOnLoadMethod]
static void Example()
{
EditorApplication.projectWindowItemOnGUI += OnGUI;
}
static void OnGUI( string guid, Rect selectionRect )
{
var pos = selectionRect;
pos.x = pos.xMax - 16;
pos.width = 16;
if ( !GUI.Button( pos, "!" ) ){ return; }
var path = AssetDatabase.GUIDToAssetPath( guid );
path = path.Replace( "/", "¥¥" );
Process.Start( "explorer.exe", "/select," + path );
}
}
- 56. /68
Sceneビューの拡張
56
using UnityEditor;
using UnityEngine;
public class ExampleClass
{
[InitializeOnLoadMethod]
static void Example()
{
SceneView.onSceneGUIDelegate += OnGUI;
}
static void OnGUI( SceneView sceneView )
{
GUI.WindowFunction func = id =>
{
if ( GUILayout.Button( "Shaded" ) ) {}
else if ( GUILayout.Button( “Wireframe" ) ) {}
};
var rect = new Rect( 8, 24, 80, 0 );
GUILayout.Window( 1, rect, func, string.Empty );
}
}