The WindowAction attribute allows you to add global actions to the windows (items in the generic menu or extra buttons).
The EditorHeaderItem attribute allows you to add extra buttons to the editor in inspector.
The WindowAction attribute allows you to add global actions to the windows (items in the generic menu or extra buttons).
The EditorHeaderItem attribute allows you to add extra buttons to the editor in inspector.
using System; | |
using UnityEditor; | |
using UnityEngine; | |
using Object = UnityEngine.Object; | |
public static class EditorHeaderItemImplementationTest | |
{ | |
// An example of implementing EditorHeaderItem. | |
// The EditorHeaderItem attribute allows you to add extra buttons to the editor in inspector. | |
[EditorHeaderItem(typeof(Transform))] | |
private static bool TransformEditorHeaderItem(Rect pos, Object[] targets) | |
{ | |
// Skip if the target is not Transform. | |
if (targets.Length == 0 || !(targets[0] is Transform)) return false; | |
var icon = EditorGUIUtility.FindTexture("refresh"); | |
if (GUI.Button(pos, icon, "IconButton")) | |
{ | |
Array.ForEach(targets, x => Debug.Log($"{x} Do something...")); | |
} | |
// If you draw UI, return true. | |
return true; | |
} | |
} |
{ | |
"name": "Unity.InternalAPIEditorBridge.001", | |
"rootNamespace": "", | |
"references": [], | |
"includePlatforms": [ | |
"Editor" | |
], | |
"excludePlatforms": [], | |
"allowUnsafeCode": false, | |
"overrideReferences": false, | |
"precompiledReferences": [], | |
"autoReferenced": false, | |
"defineConstraints": [], | |
"versionDefines": [], | |
"noEngineReferences": false | |
} |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public static class WindowActionImplementationTest | |
{ | |
// An example of implementing WindowAction. | |
// The WindowAction attribute allows you to add global actions to the windows (items in the generic menu or extra buttons). | |
[WindowAction] | |
private static WindowAction CreateWindowAction() | |
{ | |
var action = WindowAction.CreateWindowMenuItem("WindowActionTest", null, null); | |
// Show only in the Inspector window | |
action.validateHandler = (window, windowAction) => window is InspectorWindow; | |
// Add a menu to the Editor | |
action.menuPath = "Test/WindowActionTest"; | |
// Icon specification | |
action.width = 17f; | |
action.icon = EditorGUIUtility.FindTexture("record on"); | |
// (Optional) If you create a GUI callback, return true to execute executeHandler | |
action.drawHandler = (window, windowAction, pos) => | |
GUI.Button(pos, EditorGUIUtility.IconContent("record on"), "IconButton"); | |
// Execute when the icon or menu is clicked | |
action.executeHandler = (window, windowAction) => Debug.Log($"{window}: Clicked!"); | |
// You can pass a custom object to the callback | |
action.userData = new HashSet<string>(); | |
// Priority (The larger the value, the more left it is placed) | |
action.priority = 1000; | |
return action; | |
} | |
} |
Really really cool! I never notice that was a way to work around the internal unity classes using asmdef! I definitely few like I got 3 new editor super powers. thank you so much