@tool
extends EditorPlugin
func _enter_tree() -> void:
# inject the new button. when it's pressed, check if the selected file is an image. if so, generate the bitmap and so on.
pass
func _exit_tree() -> void:
# Clean-up of the plugin goes here.
pass
I don’t think they menu is exposed to scripting directly but it’s possible to modify it:
@tool
extends EditorPlugin
const ENTRY_ID = 9696
func _enter_tree() -> void:
# Get the filesystem dock and find all its popup menues
var fs = EditorInterface.get_file_system_dock()
var popup_menues = fs.find_children("*", "PopupMenu", false, false)
for popup_menu:PopupMenu in popup_menues:
# Connect to the about_to_popup signal in a deferred way so we can add an item
# after it's been filled
popup_menu.about_to_popup.connect(_on_popup_menu_about_to_popup.bind(popup_menu), CONNECT_DEFERRED)
# Connect to the id_pressed signal to react to it
popup_menu.id_pressed.connect(_on_popup_menu_id_clicked)
func _exit_tree() -> void:
# Clean-up
var fs = EditorInterface.get_file_system_dock()
var popup_menues = fs.find_children("*", "PopupMenu", false, false)
for popup_menu:PopupMenu in popup_menues:
popup_menu.about_to_popup.disconnect(_on_popup_menu_about_to_popup)
popup_menu.id_pressed.disconnect(_on_popup_menu_id_clicked)
func _on_popup_menu_about_to_popup(popup_menu:PopupMenu) -> void:
# If the new item entry hasn't been added
if popup_menu.get_item_index(ENTRY_ID) == -1:
# add it
popup_menu.add_item("NEW ITEM", ENTRY_ID)
func _on_popup_menu_id_clicked(id:int) -> void:
# If the id is the new item entry we added then do whatever we need to do
if id == ENTRY_ID:
print("NEW ITEM ENTRY CLICKED")