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.

ScriptEditor

继承: PanelContainer < Container < Control < CanvasItem < Node < Object

Godot 编辑器的脚本编辑器。

描述

Godot 编辑器的脚本编辑器。

注意:这个类不应该被直接实例化。请使用 EditorInterface.get_script_editor() 来访问这个单例。

方法

PackedStringArray

get_breakpoints()

ScriptEditorBase

get_current_editor() const

Script

get_current_script()

Array[ScriptEditorBase]

get_open_script_editors() const

Array[Script]

get_open_scripts() const

void

goto_help(topic: String)

void

goto_line(line_number: int)

void

open_script_create_dialog(base_name: String, base_path: String)

void

register_syntax_highlighter(syntax_highlighter: EditorSyntaxHighlighter)

void

unregister_syntax_highlighter(syntax_highlighter: EditorSyntaxHighlighter)

void

update_docs_from_script(script: Script)


信号

editor_script_changed(script: Script) 🔗

当用户更改活动脚本时发出。参数是新激活的 Script


script_close(script: Script) 🔗

当编辑器即将关闭活动脚本时发出。参数是将要关闭的 Script


方法说明

PackedStringArray get_breakpoints() 🔗

返回断点数组。


ScriptEditorBase get_current_editor() const 🔗

返回用户当前正在编辑的 ScriptEditorBase 对象。


Script get_current_script() 🔗

返回当前在编辑器中处于活动状态的 Script


Array[ScriptEditorBase] get_open_script_editors() const 🔗

返回一个数组,其中包含当前在编辑器中打开的所有 ScriptEditorBase 对象。


Array[Script] get_open_scripts() const 🔗

返回一个包含当前在编辑器中打开的所有 Script 对象的数组。


void goto_help(topic: String) 🔗

打开指定主题的帮助。topic 是一个编码字符串,用于控制哪个类、方法、常量、信号、注解、属性或主题项应该被关注。

支持的 topic 格式包括 class_name:classclass_method:class:methodclass_constant:class:constantclass_signal:class:signalclass_annotation:class:@annotationclass_property:class:propertyclass_theme_item:class:item,其中 class 为类名,method 为方法名,constant 为常量名,signal 为信号名,annotation 为注解名,property 为属性名,item 为主题项。

# 显示 Node 类的帮助。
class_name:Node
# 显示全局 min 函数的帮助。
# 全局对象可在 `@GlobalScope` 命名空间中访问,如下所示。
class_method:@GlobalScope:min
# 显示 Node 类中 get_viewport 的帮助。
class_method:Node:get_viewport
# 显示输入常量 MOUSE_BUTTON_MIDDLE 的帮助。
class_constant:Input:MOUSE_BUTTON_MIDDLE
# 显示 BaseButton 信号 pressed 的帮助。
class_signal:BaseButton:pressed
# 显示 CanvasItem 属性 visible 的帮助。
class_property:CanvasItem:visible
# 显示 GDScript 注解 export 的帮助。
# 注解应在描述符中以 `@` 符号为前缀,如下所示。
class_annotation:@GDScript:@export
# 显示名为 panel_selected 的 GraphNode 主题项的帮助。
class_theme_item:GraphNode:panel_selected

void goto_line(line_number: int) 🔗

转到当前脚本中的指定行。


void open_script_create_dialog(base_name: String, base_path: String) 🔗

打开创建脚本对话框。脚本将扩展 base_name。文件扩展名可以从 base_path 中省略,会根据所选择的脚本语言添加。


void register_syntax_highlighter(syntax_highlighter: EditorSyntaxHighlighter) 🔗

向编辑器注册该 EditorSyntaxHighlighter,打开的所有脚本都可以使用这个 EditorSyntaxHighlighter

注意:不适用于已经打开的脚本。


void unregister_syntax_highlighter(syntax_highlighter: EditorSyntaxHighlighter) 🔗

从编辑器注销该 EditorSyntaxHighlighter

注意:已经打开的脚本仍然适用该 EditorSyntaxHighlighter


void update_docs_from_script(script: Script) 🔗

如果 script 脚本的文档当前是打开状态,则更新该文档。

注意:每当脚本发生更改时都应调用该方法,从而保持打开文档的状态为最新。