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 编辑器的命令面板。
描述
该对象包含所有可用命令及其快捷方式文本。这些命令可以通过 编辑器 > 命令面板 菜单访问。
命令键名使用斜杠分隔符来区分部分,例如:"example/command1"
,那么 example
将是部分名称。
var command_palette = EditorInterface.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 = EditorInterface.Singleton.GetCommandPalette();
// ExternalCommand 是将在命令执行时调用的函数。
Callable commandCallable = new Callable(this, MethodName.ExternalCommand);
commandPalette.AddCommand("command", "test/command", commandCallable)
注意:不应直接实例化此类。相反,使用 EditorInterface.get_command_palette() 访问单例。
属性
dialog_hide_on_ok |
|
方法
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 的键名)