Created
March 2, 2024 05:21
-
-
Save cmargroff/318d826b52cb9dc64d1604b38c18d7d7 to your computer and use it in GitHub Desktop.
Godot editor plugin extensions for getting the top menu bar items to add your own menu items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
// This was tested against 4.2.stable.mono | |
#if TOOLS | |
[Tool] | |
public static class EditorPluginExtensions | |
{ | |
public static PopupMenu GetTopMenuItem(this EditorPlugin editorPlugin, string name) | |
{ | |
var root = EditorInterface.Singleton.GetBaseControl(); | |
return root | |
.FindChild("*EditorTitleBar*", true, false) | |
.FindChild(name, true, false) as PopupMenu; | |
} | |
public static PopupMenu GetSceneMenu(this EditorPlugin editorPlugin) | |
{ | |
return editorPlugin.GetTopMenuItem("Scene"); | |
} | |
public static PopupMenu GetProjectMenu(this EditorPlugin editorPlugin) | |
{ | |
return editorPlugin.GetTopMenuItem("Project"); | |
} | |
public static PopupMenu GetDebugMenu(this EditorPlugin editorPlugin) | |
{ | |
return editorPlugin.GetTopMenuItem("Debug"); | |
} | |
public static PopupMenu GetEditorMenu(this EditorPlugin editorPlugin) | |
{ | |
return editorPlugin.GetTopMenuItem("Editor"); | |
} | |
public static PopupMenu GetHelpMenu(this EditorPlugin editorPlugin) | |
{ | |
return editorPlugin.GetTopMenuItem("Help"); | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment