Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
EditorCommandPalette
繼承: ConfirmationDialog < AcceptDialog < Window < Viewport < Node < Object
Godot 編輯器的命令面板。
說明
該物件包含所有可用命令及其快捷方式文字。這些命令可以通過 Editor > 命令面板 選單存取。
命令鍵名使用斜杠分隔符號來區分部分,例如:"example/command1",那麼 example 將是部分名稱。
var command_palette = get_editor_interface().get_command_palette()
# external_command 是將在命令執行時呼叫的函式。
var command_callable = Callable(self, "external_command").bind(arguments)
command_palette.add_command("command", "test/command",command_callable)
EditorCommandPalette commandPalette = GetEditorInterface().GetCommandPalette();
// ExternalCommand 是將在命令執行時呼叫的函式。
Callable commandCallable = new Callable(this, MethodName.ExternalCommand);
commandPalette.AddCommand("command", "test/command", commandCallable)
注意:不應直接產生實體此類。相反,使用 EditorInterface.get_command_palette() 存取單例。
方法
void |
add_command(command_name: String, key_name: String, binded_callable: Callable, shortcut_text: String = "None") |
void |
remove_command(key_name: String) |
方法說明
void add_command(command_name: String, key_name: String, binded_callable: Callable, shortcut_text: String = "None") 🔗
向 EditorCommandPalette 新增自訂命令。
command_name:String(Command 的名稱。這會顯示給使用者。)key_name:String(特定 Command 的金鑰名稱。這用於唯一標識 Command。)binded_callable:Callable(Command 的 Callable。這將在選擇 Command 時執行。)shortcut_text:String(Command 的快捷鍵文字,如果可用。)
void remove_command(key_name: String) 🔗
從 EditorCommandPalette 中刪除自訂命令。
key_name: String (特定 Command 的鍵名)