Debian Codegraph @

doc/classes/EditorInterface.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="EditorInterface" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Godot editor's interface.
5 </brief_description>
6 <description>
7 [EditorInterface] gives you control over Godot editor's window. It allows customizing the window, saving and (re-)loading scenes, rendering mesh previews, inspecting and editing resources and objects, and provides access to [EditorSettings], [EditorFileSystem], [EditorResourcePreview], [ScriptEditor], the editor viewport, and information about scenes.
8 [b]Note:[/b] This class shouldn't be instantiated directly. Instead, access the singleton directly by its name.
9 [codeblocks]
10 [gdscript]
11 var editor_settings = EditorInterface.get_editor_settings()
12 [/gdscript]
13 [csharp]
14 // In C# you can access it via the static Singleton property.
15 EditorSettings settings = EditorInterface.Singleton.GetEditorSettings();
16 [/csharp]
17 [/codeblocks]
18 </description>
19 <tutorials>
20 </tutorials>
21 <methods>
22 <method name="add_root_node">
23 <return type="void" />
24 <param index="0" name="node" type="Node" />
25 <description>
26 Makes [param node] root of the currently opened scene. Only works if the scene is empty. If the [param node] is a scene instance, an inheriting scene will be created.
27 </description>
28 </method>
29 <method name="close_scene">
30 <return type="int" enum="Error" />
31 <description>
32 Closes the currently active scene, discarding any pending changes in the process. Returns [constant OK] on success or [constant ERR_DOES_NOT_EXIST] if there is no scene to close.
33 </description>
34 </method>
35 <method name="edit_node">
36 <return type="void" />
37 <param index="0" name="node" type="Node" />
38 <description>
39 Edits the given [Node]. The node will be also selected if it's inside the scene tree.
40 </description>
41 </method>
42 <method name="edit_resource">
43 <return type="void" />
44 <param index="0" name="resource" type="Resource" />
45 <description>
46 Edits the given [Resource]. If the resource is a [Script] you can also edit it with [method edit_script] to specify the line and column position.
47 </description>
48 </method>
49 <method name="edit_script">
50 <return type="void" />
51 <param index="0" name="script" type="Script" />
52 <param index="1" name="line" type="int" default="-1" />
53 <param index="2" name="column" type="int" default="0" />
54 <param index="3" name="grab_focus" type="bool" default="true" />
55 <description>
56 Edits the given [Script]. The line and column on which to open the script can also be specified. The script will be open with the user-configured editor for the script's language which may be an external editor.
57 </description>
58 </method>
59 <method name="get_base_control" qualifiers="const">
60 <return type="Control" />
61 <description>
62 Returns the main container of Godot editor's window. For example, you can use it to retrieve the size of the container and place your controls accordingly.
63 [b]Warning:[/b] Removing and freeing this node will render the editor useless and may cause a crash.
64 </description>
65 </method>
66 <method name="get_command_palette" qualifiers="const">
67 <return type="EditorCommandPalette" />
68 <description>
69 Returns the editor's [EditorCommandPalette] instance.
70 [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
71 </description>
72 </method>
73 <method name="get_current_directory" qualifiers="const">
74 <return type="String" />
75 <description>
76 Returns the current directory being viewed in the [FileSystemDock]. If a file is selected, its base directory will be returned using [method String.get_base_dir] instead.
77 </description>
78 </method>
79 <method name="get_current_feature_profile" qualifiers="const">
80 <return type="String" />
81 <description>
82 Returns the name of the currently activated feature profile. If the default profile is currently active, an empty string is returned instead.
83 In order to get a reference to the [EditorFeatureProfile], you must load the feature profile using [method EditorFeatureProfile.load_from_file].
84 [b]Note:[/b] Feature profiles created via the user interface are loaded from the [code]feature_profiles[/code] directory, as a file with the [code].profile[/code] extension. The editor configuration folder can be found by using [method EditorPaths.get_config_dir].
85 </description>
86 </method>
87 <method name="get_current_path" qualifiers="const">
88 <return type="String" />
89 <description>
90 Returns the current path being viewed in the [FileSystemDock].
91 </description>
92 </method>
93 <method name="get_edited_scene_root" qualifiers="const">
94 <return type="Node" />
95 <description>
96 Returns the edited (current) scene's root [Node].
97 </description>
98 </method>
99 <method name="get_editor_language" qualifiers="const">
100 <return type="String" />
101 <description>
102 Returns the language currently used for the editor interface.
103 </description>
104 </method>
105 <method name="get_editor_main_screen" qualifiers="const">
106 <return type="VBoxContainer" />
107 <description>
108 Returns the editor control responsible for main screen plugins and tools. Use it with plugins that implement [method EditorPlugin._has_main_screen].
109 [b]Note:[/b] This node is a [VBoxContainer], which means that if you add a [Control] child to it, you need to set the child's [member Control.size_flags_vertical] to [constant Control.SIZE_EXPAND_FILL] to make it use the full available space.
110 [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
111 </description>
112 </method>
113 <method name="get_editor_paths" qualifiers="const">
114 <return type="EditorPaths" />
115 <description>
116 Returns the [EditorPaths] singleton.
117 </description>
118 </method>
119 <method name="get_editor_scale" qualifiers="const">
120 <return type="float" />
121 <description>
122 Returns the actual scale of the editor UI ([code]1.0[/code] being 100% scale). This can be used to adjust position and dimensions of the UI added by plugins.
123 [b]Note:[/b] This value is set via the [member EditorSettings.interface/editor/display_scale] and [member EditorSettings.interface/editor/custom_display_scale] settings. The editor must be restarted for changes to be properly applied.
124 </description>
125 </method>
126 <method name="get_editor_settings" qualifiers="const">
127 <return type="EditorSettings" />
128 <description>
129 Returns the editor's [EditorSettings] instance.
130 </description>
131 </method>
132 <method name="get_editor_theme" qualifiers="const">
133 <return type="Theme" />
134 <description>
135 Returns the editor's [Theme].
136 [b]Note:[/b] When creating custom editor UI, prefer accessing theme items directly from your GUI nodes using the [code]get_theme_*[/code] methods.
137 </description>
138 </method>
139 <method name="get_editor_toaster" qualifiers="const">
140 <return type="EditorToaster" />
141 <description>
142 Returns the editor's [EditorToaster].
143 </description>
144 </method>
145 <method name="get_editor_undo_redo" qualifiers="const">
146 <return type="EditorUndoRedoManager" />
147 <description>
148 Returns the editor's [EditorUndoRedoManager].
149 </description>
150 </method>
151 <method name="get_editor_viewport_2d" qualifiers="const">
152 <return type="SubViewport" />
153 <description>
154 Returns the 2D editor [SubViewport]. It does not have a camera. Instead, the view transforms are done directly and can be accessed with [member Viewport.global_canvas_transform].
155 </description>
156 </method>
157 <method name="get_editor_viewport_3d" qualifiers="const">
158 <return type="SubViewport" />
159 <param index="0" name="idx" type="int" default="0" />
160 <description>
161 Returns the specified 3D editor [SubViewport], from [code]0[/code] to [code]3[/code]. The viewport can be used to access the active editor cameras with [method Viewport.get_camera_3d].
162 </description>
163 </method>
164 <method name="get_file_system_dock" qualifiers="const">
165 <return type="FileSystemDock" />
166 <description>
167 Returns the editor's [FileSystemDock] instance.
168 [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
169 </description>
170 </method>
171 <method name="get_inspector" qualifiers="const">
172 <return type="EditorInspector" />
173 <description>
174 Returns the editor's [EditorInspector] instance.
175 [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
176 </description>
177 </method>
178 <method name="get_node_3d_rotate_snap" qualifiers="const">
179 <return type="float" />
180 <description>
181 Returns the amount of degrees the 3D editor's rotational snapping is set to.
182 </description>
183 </method>
184 <method name="get_node_3d_scale_snap" qualifiers="const">
185 <return type="float" />
186 <description>
187 Returns the amount of units the 3D editor's scale snapping is set to.
188 </description>
189 </method>
190 <method name="get_node_3d_translate_snap" qualifiers="const">
191 <return type="float" />
192 <description>
193 Returns the amount of units the 3D editor's translation snapping is set to.
194 </description>
195 </method>
196 <method name="get_open_scene_roots" qualifiers="const">
197 <return type="Node[]" />
198 <description>
199 Returns an array with references to the root nodes of the currently opened scenes.
200 </description>
201 </method>
202 <method name="get_open_scenes" qualifiers="const">
203 <return type="PackedStringArray" />
204 <description>
205 Returns an array with the file paths of the currently opened scenes.
206 </description>
207 </method>
208 <method name="get_playing_scene" qualifiers="const">
209 <return type="String" />
210 <description>
211 Returns the name of the scene that is being played. If no scene is currently being played, returns an empty string.
212 </description>
213 </method>
214 <method name="get_resource_filesystem" qualifiers="const">
215 <return type="EditorFileSystem" />
216 <description>
217 Returns the editor's [EditorFileSystem] instance.
218 </description>
219 </method>
220 <method name="get_resource_previewer" qualifiers="const">
221 <return type="EditorResourcePreview" />
222 <description>
223 Returns the editor's [EditorResourcePreview] instance.
224 </description>
225 </method>
226 <method name="get_script_editor" qualifiers="const">
227 <return type="ScriptEditor" />
228 <description>
229 Returns the editor's [ScriptEditor] instance.
230 [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
231 </description>
232 </method>
233 <method name="get_selected_paths" qualifiers="const">
234 <return type="PackedStringArray" />
235 <description>
236 Returns an array containing the paths of the currently selected files (and directories) in the [FileSystemDock].
237 </description>
238 </method>
239 <method name="get_selection" qualifiers="const">
240 <return type="EditorSelection" />
241 <description>
242 Returns the editor's [EditorSelection] instance.
243 </description>
244 </method>
245 <method name="inspect_object">
246 <return type="void" />
247 <param index="0" name="object" type="Object" />
248 <param index="1" name="for_property" type="String" default="&quot;&quot;" />
249 <param index="2" name="inspector_only" type="bool" default="false" />
250 <description>
251 Shows the given property on the given [param object] in the editor's Inspector dock. If [param inspector_only] is [code]true[/code], plugins will not attempt to edit [param object].
252 </description>
253 </method>
254 <method name="is_multi_window_enabled" qualifiers="const">
255 <return type="bool" />
256 <description>
257 Returns [code]true[/code] if multiple window support is enabled in the editor. Multiple window support is enabled if [i]all[/i] of these statements are true:
258 - [member EditorSettings.interface/multi_window/enable] is [code]true[/code].
259 - [member EditorSettings.interface/editor/single_window_mode] is [code]false[/code].
260 - [member Viewport.gui_embed_subwindows] is [code]false[/code]. This is forced to [code]true[/code] on platforms that don't support multiple windows such as Web, or when the [code]--single-window[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url] is used.
261 </description>
262 </method>
263 <method name="is_node_3d_snap_enabled" qualifiers="const">
264 <return type="bool" />
265 <description>
266 Returns [code]true[/code] if the 3D editor currently has snapping mode enabled, and [code]false[/code] otherwise.
267 </description>
268 </method>
269 <method name="is_object_edited" qualifiers="const">
270 <return type="bool" />
271 <param index="0" name="object" type="Object" />
272 <description>
273 Returns [code]true[/code] if the object has been marked as edited through [method set_object_edited].
274 </description>
275 </method>
276 <method name="is_playing_scene" qualifiers="const">
277 <return type="bool" />
278 <description>
279 Returns [code]true[/code] if a scene is currently being played, [code]false[/code] otherwise. Paused scenes are considered as being played.
280 </description>
281 </method>
282 <method name="is_plugin_enabled" qualifiers="const">
283 <return type="bool" />
284 <param index="0" name="plugin" type="String" />
285 <description>
286 Returns [code]true[/code] if the specified [param plugin] is enabled. The plugin name is the same as its directory name.
287 </description>
288 </method>
289 <method name="make_mesh_previews">
290 <return type="Texture2D[]" />
291 <param index="0" name="meshes" type="Mesh[]" />
292 <param index="1" name="preview_size" type="int" />
293 <description>
294 Returns mesh previews rendered at the given size as an [Array] of [Texture2D]s.
295 </description>
296 </method>
297 <method name="mark_scene_as_unsaved">
298 <return type="void" />
299 <description>
300 Marks the current scene tab as unsaved.
301 </description>
302 </method>
303 <method name="open_scene_from_path">
304 <return type="void" />
305 <param index="0" name="scene_filepath" type="String" />
306 <param index="1" name="set_inherited" type="bool" default="false" />
307 <description>
308 Opens the scene at the given path. If [param set_inherited] is [code]true[/code], creates a new inherited scene.
309 </description>
310 </method>
311 <method name="play_current_scene">
312 <return type="void" />
313 <description>
314 Plays the currently active scene.
315 </description>
316 </method>
317 <method name="play_custom_scene">
318 <return type="void" />
319 <param index="0" name="scene_filepath" type="String" />
320 <description>
321 Plays the scene specified by its filepath.
322 </description>
323 </method>
324 <method name="play_main_scene">
325 <return type="void" />
326 <description>
327 Plays the main scene.
328 </description>
329 </method>
330 <method name="popup_create_dialog" experimental="">
331 <return type="void" />
332 <param index="0" name="callback" type="Callable" />
333 <param index="1" name="base_type" type="StringName" default="&quot;&quot;" />
334 <param index="2" name="current_type" type="String" default="&quot;&quot;" />
335 <param index="3" name="dialog_title" type="String" default="&quot;&quot;" />
336 <param index="4" name="type_blocklist" type="StringName[]" default="[]" />
337 <description>
338 Pops up an editor dialog for creating an object.
339 The [param callback] must take a single argument of type [String], which will contain the type name of the selected object (or the script path of the type, if the type is created from a script), or be an empty string if no item is selected.
340 The [param base_type] specifies the base type of objects to display. For example, if you set this to "Resource", all types derived from [Resource] will display in the create dialog.
341 The [param current_type] will be passed in the search box of the create dialog, and the specified type can be immediately selected when the dialog pops up. If the [param current_type] is not derived from [param base_type], there will be no result of the type in the dialog.
342 The [param dialog_title] allows you to define a custom title for the dialog. This is useful if you want to accurately hint the usage of the dialog. If the [param dialog_title] is an empty string, the dialog will use "Create New 'Base Type'" as the default title.
343 The [param type_blocklist] contains a list of type names, and the types in the blocklist will be hidden from the create dialog.
344 [b]Note:[/b] Trying to list the base type in the [param type_blocklist] will hide all types derived from the base type from the create dialog.
345 </description>
346 </method>
347 <method name="popup_dialog">
348 <return type="void" />
349 <param index="0" name="dialog" type="Window" />
350 <param index="1" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" />
351 <description>
352 Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive]. The dialog must have no current parent, otherwise the method fails.
353 See also [method Window.set_unparent_when_invisible].
354 </description>
355 </method>
356 <method name="popup_dialog_centered">
357 <return type="void" />
358 <param index="0" name="dialog" type="Window" />
359 <param index="1" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
360 <description>
361 Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive_centered]. The dialog must have no current parent, otherwise the method fails.
362 See also [method Window.set_unparent_when_invisible].
363 </description>
364 </method>
365 <method name="popup_dialog_centered_clamped">
366 <return type="void" />
367 <param index="0" name="dialog" type="Window" />
368 <param index="1" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
369 <param index="2" name="fallback_ratio" type="float" default="0.75" />
370 <description>
371 Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive_centered_clamped]. The dialog must have no current parent, otherwise the method fails.
372 See also [method Window.set_unparent_when_invisible].
373 </description>
374 </method>
375 <method name="popup_dialog_centered_ratio">
376 <return type="void" />
377 <param index="0" name="dialog" type="Window" />
378 <param index="1" name="ratio" type="float" default="0.8" />
379 <description>
380 Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive_centered_ratio]. The dialog must have no current parent, otherwise the method fails.
381 See also [method Window.set_unparent_when_invisible].
382 </description>
383 </method>
384 <method name="popup_method_selector">
385 <return type="void" />
386 <param index="0" name="object" type="Object" />
387 <param index="1" name="callback" type="Callable" />
388 <param index="2" name="current_value" type="String" default="&quot;&quot;" />
389 <description>
390 Pops up an editor dialog for selecting a method from [param object]. The [param callback] must take a single argument of type [String] which will contain the name of the selected method or be empty if the dialog is canceled. If [param current_value] is provided, the method will be selected automatically in the method list, if it exists.
391 </description>
392 </method>
393 <method name="popup_node_selector">
394 <return type="void" />
395 <param index="0" name="callback" type="Callable" />
396 <param index="1" name="valid_types" type="StringName[]" default="[]" />
397 <param index="2" name="current_value" type="Node" default="null" />
398 <description>
399 Pops up an editor dialog for selecting a [Node] from the edited scene. The [param callback] must take a single argument of type [NodePath]. It is called on the selected [NodePath] or the empty path [code]^""[/code] if the dialog is canceled. If [param valid_types] is provided, the dialog will only show Nodes that match one of the listed Node types. If [param current_value] is provided, the Node will be automatically selected in the tree, if it exists.
400 [b]Example:[/b] Display the node selection dialog as soon as this node is added to the tree for the first time:
401 [codeblock]
402 func _ready():
403 if Engine.is_editor_hint():
404 EditorInterface.popup_node_selector(_on_node_selected, ["Button"])
405
406 func _on_node_selected(node_path):
407 if node_path.is_empty():
408 print("node selection canceled")
409 else:
410 print("selected ", node_path)
411 [/codeblock]
412 </description>
413 </method>
414 <method name="popup_property_selector">
415 <return type="void" />
416 <param index="0" name="object" type="Object" />
417 <param index="1" name="callback" type="Callable" />
418 <param index="2" name="type_filter" type="PackedInt32Array" default="PackedInt32Array()" />
419 <param index="3" name="current_value" type="String" default="&quot;&quot;" />
420 <description>
421 Pops up an editor dialog for selecting properties from [param object]. The [param callback] must take a single argument of type [NodePath]. It is called on the selected property path (see [method NodePath.get_as_property_path]) or the empty path [code]^""[/code] if the dialog is canceled. If [param type_filter] is provided, the dialog will only show properties that match one of the listed [enum Variant.Type] values. If [param current_value] is provided, the property will be selected automatically in the property list, if it exists.
422 [codeblock]
423 func _ready():
424 if Engine.is_editor_hint():
425 EditorInterface.popup_property_selector(this, _on_property_selected, [TYPE_INT])
426
427 func _on_property_selected(property_path):
428 if property_path.is_empty():
429 print("property selection canceled")
430 else:
431 print("selected ", property_path)
432 [/codeblock]
433 </description>
434 </method>
435 <method name="popup_quick_open">
436 <return type="void" />
437 <param index="0" name="callback" type="Callable" />
438 <param index="1" name="base_types" type="StringName[]" default="[]" />
439 <description>
440 Pops up an editor dialog for quick selecting a resource file. The [param callback] must take a single argument of type [String] which will contain the path of the selected resource or be empty if the dialog is canceled. If [param base_types] is provided, the dialog will only show resources that match these types. Only types deriving from [Resource] are supported.
441 </description>
442 </method>
443 <method name="reload_scene_from_path">
444 <return type="void" />
445 <param index="0" name="scene_filepath" type="String" />
446 <description>
447 Reloads the scene at the given path.
448 </description>
449 </method>
450 <method name="restart_editor">
451 <return type="void" />
452 <param index="0" name="save" type="bool" default="true" />
453 <description>
454 Restarts the editor. This closes the editor and then opens the same project. If [param save] is [code]true[/code], the project will be saved before restarting.
455 </description>
456 </method>
457 <method name="save_all_scenes">
458 <return type="void" />
459 <description>
460 Saves all opened scenes in the editor.
461 </description>
462 </method>
463 <method name="save_scene">
464 <return type="int" enum="Error" />
465 <description>
466 Saves the currently active scene. Returns either [constant OK] or [constant ERR_CANT_CREATE].
467 </description>
468 </method>
469 <method name="save_scene_as">
470 <return type="void" />
471 <param index="0" name="path" type="String" />
472 <param index="1" name="with_preview" type="bool" default="true" />
473 <description>
474 Saves the currently active scene as a file at [param path].
475 </description>
476 </method>
477 <method name="select_file">
478 <return type="void" />
479 <param index="0" name="file" type="String" />
480 <description>
481 Selects the file, with the path provided by [param file], in the FileSystem dock.
482 </description>
483 </method>
484 <method name="set_current_feature_profile">
485 <return type="void" />
486 <param index="0" name="profile_name" type="String" />
487 <description>
488 Selects and activates the specified feature profile with the given [param profile_name]. Set [param profile_name] to an empty string to reset to the default feature profile.
489 A feature profile can be created programmatically using the [EditorFeatureProfile] class.
490 [b]Note:[/b] The feature profile that gets activated must be located in the [code]feature_profiles[/code] directory, as a file with the [code].profile[/code] extension. If a profile could not be found, an error occurs. The editor configuration folder can be found by using [method EditorPaths.get_config_dir].
491 </description>
492 </method>
493 <method name="set_main_screen_editor">
494 <return type="void" />
495 <param index="0" name="name" type="String" />
496 <description>
497 Sets the editor's current main screen to the one specified in [param name]. [param name] must match the title of the tab in question exactly (e.g. [code]2D[/code], [code]3D[/code], [code skip-lint]Script[/code], [code]Game[/code], or [code]AssetLib[/code] for default tabs).
498 </description>
499 </method>
500 <method name="set_object_edited">
501 <return type="void" />
502 <param index="0" name="object" type="Object" />
503 <param index="1" name="edited" type="bool" />
504 <description>
505 If [param edited] is [code]true[/code], the object is marked as edited.
506 [b]Note:[/b] This is primarily used by the editor for [Resource] based objects to track their modified state. For example, any changes to an open scene, a resource in the inspector, or an edited script will cause this method to be called with [code]true[/code]. Saving the scene, script, or resource resets the edited state by calling this method with [code]false[/code].
507 [b]Note:[/b] Each call to this method increments the object's edited version. This is used to track changes in the editor and to trigger when thumbnails should be regenerated for resources.
508 </description>
509 </method>
510 <method name="set_plugin_enabled">
511 <return type="void" />
512 <param index="0" name="plugin" type="String" />
513 <param index="1" name="enabled" type="bool" />
514 <description>
515 Sets the enabled status of a plugin. The plugin name is the same as its directory name.
516 </description>
517 </method>
518 <method name="stop_playing_scene">
519 <return type="void" />
520 <description>
521 Stops the scene that is currently playing.
522 </description>
523 </method>
524 </methods>
525 <members>
526 <member name="distraction_free_mode" type="bool" setter="set_distraction_free_mode" getter="is_distraction_free_mode_enabled">
527 If [code]true[/code], enables distraction-free mode which hides side docks to increase the space available for the main view.
528 </member>
529 <member name="movie_maker_enabled" type="bool" setter="set_movie_maker_enabled" getter="is_movie_maker_enabled">
530 If [code]true[/code], the Movie Maker mode is enabled in the editor. See [MovieWriter] for more information.
531 </member>
532 </members>
533 </class>