Table of Contents

Class EditorInterface

Godot editor's interface.

Inheritance
EditorInterface

Remarks

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.

Note: This class shouldn't be instantiated directly. Instead, access the singleton directly by its name.

var editor_settings = EditorInterface.get_editor_settings()

Properties

distraction_free_mode

If true, enables distraction-free mode which hides side docks to increase the space available for the main view.

var distraction_free_mode : bool

Property Value

bool

Remarks

  • void set_distraction_free_mode(bool value)
  • bool is_distraction_free_mode_enabled

movie_maker_enabled

If true, the Movie Maker mode is enabled in the editor. See MovieWriter for more information.

var movie_maker_enabled : bool

Property Value

bool

Remarks

  • void set_movie_maker_enabled(bool value)
  • bool is_movie_maker_enabled

Methods

edit_node(Node)

Edits the given Node. The node will be also selected if it's inside the scene tree.

void edit_node(Node node)

Parameters

node Node

edit_resource(Resource)

Edits the given Resource. If the resource is a Script you can also edit it with EditorInterface.edit_script to specify the line and column position.

void edit_resource(Resource resource)

Parameters

resource Resource

edit_script(Script, int, int, bool)

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.

void edit_script(Script script, int line, int column, bool grab_focus)

Parameters

script Script
line int
column int
grab_focus bool

get_base_control

Qualifiers: const

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.

Warning: Removing and freeing this node will render the editor useless and may cause a crash.

Control get_base_control

get_command_palette

Qualifiers: const

Returns the editor's EditorCommandPalette instance.

Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.

EditorCommandPalette get_command_palette

get_current_directory

Qualifiers: const

Returns the current directory being viewed in the FileSystemDock. If a file is selected, its base directory will be returned using get_base_dir instead.

String get_current_directory

get_current_feature_profile

Qualifiers: const

Returns the name of the currently activated feature profile. If the default profile is currently active, an empty string is returned instead.

In order to get a reference to the EditorFeatureProfile, you must load the feature profile using EditorFeatureProfile.load_from_file.

Note: Feature profiles created via the user interface are loaded from the feature_profiles directory, as a file with the .profile extension. The editor configuration folder can be found by using get_config_dir.

String get_current_feature_profile

get_current_path

Qualifiers: const

Returns the current path being viewed in the FileSystemDock.

String get_current_path

get_edited_scene_root

Qualifiers: const

Returns the edited (current) scene's root Node.

Node get_edited_scene_root

get_editor_main_screen

Qualifiers: const

Returns the editor control responsible for main screen plugins and tools. Use it with plugins that implement _has_main_screen.

Note: This node is a VBoxContainer, which means that if you add a Control child to it, you need to set the child's size_flags_vertical to Control.SIZE_EXPAND_FILL to make it use the full available space.

Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.

VBoxContainer get_editor_main_screen

get_editor_paths

Qualifiers: const

Returns the EditorPaths singleton.

EditorPaths get_editor_paths

get_editor_scale

Qualifiers: const

Returns the actual scale of the editor UI (1.0 being 100% scale). This can be used to adjust position and dimensions of the UI added by plugins.

Note: This value is set via the interface/editor/display_scale and interface/editor/custom_display_scale editor settings. Editor must be restarted for changes to be properly applied.

float get_editor_scale

get_editor_settings

Qualifiers: const

Returns the editor's EditorSettings instance.

EditorSettings get_editor_settings

get_editor_theme

Qualifiers: const

Returns the editor's Theme.

Note: When creating custom editor UI, prefer accessing theme items directly from your GUI nodes using the get_theme_* methods.

Theme get_editor_theme

get_editor_toaster

Qualifiers: const

Returns the editor's EditorToaster.

EditorToaster get_editor_toaster

get_editor_undo_redo

Qualifiers: const

Returns the editor's EditorUndoRedoManager.

EditorUndoRedoManager get_editor_undo_redo

get_editor_viewport_2d

Qualifiers: const

Returns the 2D editor SubViewport. It does not have a camera. Instead, the view transforms are done directly and can be accessed with global_canvas_transform.

SubViewport get_editor_viewport_2d

get_editor_viewport_3d(int)

Qualifiers: const

Returns the specified 3D editor SubViewport, from 0 to 3. The viewport can be used to access the active editor cameras with get_camera_3d.

SubViewport get_editor_viewport_3d(int idx)

Parameters

idx int

get_file_system_dock

Qualifiers: const

Returns the editor's FileSystemDock instance.

Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.

FileSystemDock get_file_system_dock

get_inspector

Qualifiers: const

Returns the editor's EditorInspector instance.

Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.

EditorInspector get_inspector

get_open_scenes

Qualifiers: const

Returns an Array with the file paths of the currently opened scenes.

PackedStringArray get_open_scenes

get_playing_scene

Qualifiers: const

Returns the name of the scene that is being played. If no scene is currently being played, returns an empty string.

String get_playing_scene

get_resource_filesystem

Qualifiers: const

Returns the editor's EditorFileSystem instance.

EditorFileSystem get_resource_filesystem

get_resource_previewer

Qualifiers: const

Returns the editor's EditorResourcePreview instance.

EditorResourcePreview get_resource_previewer

get_script_editor

Qualifiers: const

Returns the editor's ScriptEditor instance.

Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.

ScriptEditor get_script_editor

get_selected_paths

Qualifiers: const

Returns an array containing the paths of the currently selected files (and directories) in the FileSystemDock.

PackedStringArray get_selected_paths

get_selection

Qualifiers: const

Returns the editor's EditorSelection instance.

EditorSelection get_selection

inspect_object(Object, String, bool)

Shows the given property on the given object in the editor's Inspector dock. If inspector_only is true, plugins will not attempt to edit object.

void inspect_object(Object object, String for_property, bool inspector_only)

Parameters

object Object
for_property String
inspector_only bool

is_multi_window_enabled

Qualifiers: const

Returns true if multiple window support is enabled in the editor. Multiple window support is enabled if all of these statements are true:

bool is_multi_window_enabled

is_playing_scene

Qualifiers: const

Returns true if a scene is currently being played, false otherwise. Paused scenes are considered as being played.

bool is_playing_scene

is_plugin_enabled(String)

Qualifiers: const

Returns true if the specified plugin is enabled. The plugin name is the same as its directory name.

bool is_plugin_enabled(String plugin)

Parameters

plugin String

make_mesh_previews(Mesh[], int)

Returns mesh previews rendered at the given size as an Array of Texture2Ds.

Texture2D[] make_mesh_previews(Mesh[] meshes, int preview_size)

Parameters

meshes Mesh[]
preview_size int

mark_scene_as_unsaved

Marks the current scene tab as unsaved.

void mark_scene_as_unsaved

open_scene_from_path(String, bool)

Opens the scene at the given path. If set_inherited is true, creates a new inherited scene.

void open_scene_from_path(String scene_filepath, bool set_inherited)

Parameters

scene_filepath String
set_inherited bool

play_current_scene

Plays the currently active scene.

void play_current_scene

play_custom_scene(String)

Plays the scene specified by its filepath.

void play_custom_scene(String scene_filepath)

Parameters

scene_filepath String

play_main_scene

Plays the main scene.

void play_main_scene

popup_create_dialog(Callable, StringName, String, String, StringName[])

Pops up an editor dialog for creating an object.

The callback must take a single argument of type StringName which will contain the type name of the selected object or be empty if no item is selected.

The 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.

The 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 current_type is not derived from base_type, there will be no result of the type in the dialog.

The 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 dialog_title is an empty string, the dialog will use "Create New 'Base Type'" as the default title.

The type_blocklist contains a list of type names, and the types in the blocklist will be hidden from the create dialog.

Note: Trying to list the base type in the type_blocklist will hide all types derived from the base type from the create dialog.

void popup_create_dialog(Callable callback, StringName base_type, String current_type, String dialog_title, StringName[] type_blocklist)

Parameters

callback Callable
base_type StringName
current_type String
dialog_title String
type_blocklist StringName[]

popup_dialog(Window, Rect2i)

Pops up the dialog in the editor UI with Window.popup_exclusive. The dialog must have no current parent, otherwise the method fails.

See also Window.set_unparent_when_invisible.

void popup_dialog(Window dialog, Rect2i rect)

Parameters

dialog Window
rect Rect2i

popup_dialog_centered(Window, Vector2i)

Pops up the dialog in the editor UI with Window.popup_exclusive_centered. The dialog must have no current parent, otherwise the method fails.

See also Window.set_unparent_when_invisible.

void popup_dialog_centered(Window dialog, Vector2i minsize)

Parameters

dialog Window
minsize Vector2i

popup_dialog_centered_clamped(Window, Vector2i, float)

Pops up the dialog in the editor UI with Window.popup_exclusive_centered_clamped. The dialog must have no current parent, otherwise the method fails.

See also Window.set_unparent_when_invisible.

void popup_dialog_centered_clamped(Window dialog, Vector2i minsize, float fallback_ratio)

Parameters

dialog Window
minsize Vector2i
fallback_ratio float

popup_dialog_centered_ratio(Window, float)

Pops up the dialog in the editor UI with Window.popup_exclusive_centered_ratio. The dialog must have no current parent, otherwise the method fails.

See also Window.set_unparent_when_invisible.

void popup_dialog_centered_ratio(Window dialog, float ratio)

Parameters

dialog Window
ratio float

popup_method_selector(Object, Callable, String)

Pops up an editor dialog for selecting a method from object. The 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 current_value is provided, the method will be selected automatically in the method list, if it exists.

void popup_method_selector(Object object, Callable callback, String current_value)

Parameters

object Object
callback Callable
current_value String

popup_node_selector(Callable, StringName[], Node)

Pops up an editor dialog for selecting a Node from the edited scene. The callback must take a single argument of type NodePath. It is called on the selected NodePath or the empty path ^"" if the dialog is canceled. If valid_types is provided, the dialog will only show Nodes that match one of the listed Node types. If current_value is provided, the Node will be automatically selected in the tree, if it exists.

Example: Display the node selection dialog as soon as this node is added to the tree for the first time:

func _ready():
    if Engine.is_editor_hint():
        EditorInterface.popup_node_selector(_on_node_selected, ["Button"])

func _on_node_selected(node_path):
    if node_path.is_empty():
        print("node selection canceled")
    else:
        print("selected ", node_path)

void popup_node_selector(Callable callback, StringName[] valid_types, Node current_value)

Parameters

callback Callable
valid_types StringName[]
current_value Node

popup_property_selector(Object, Callable, PackedInt32Array, String)

Pops up an editor dialog for selecting properties from object. The callback must take a single argument of type NodePath. It is called on the selected property path (see get_as_property_path) or the empty path ^"" if the dialog is canceled. If type_filter is provided, the dialog will only show properties that match one of the listed Variant.Type values. If current_value is provided, the property will be selected automatically in the property list, if it exists.

func _ready():
    if Engine.is_editor_hint():
        EditorInterface.popup_property_selector(this, _on_property_selected, [TYPE_INT])

func _on_property_selected(property_path):
    if property_path.is_empty():
        print("property selection canceled")
    else:
        print("selected ", property_path)

void popup_property_selector(Object object, Callable callback, PackedInt32Array type_filter, String current_value)

Parameters

object Object
callback Callable
type_filter PackedInt32Array
current_value String

popup_quick_open(Callable, StringName[])

Pops up an editor dialog for quick selecting a resource file. The 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 base_types is provided, the dialog will only show resources that match these types. Only types deriving from Resource are supported.

void popup_quick_open(Callable callback, StringName[] base_types)

Parameters

callback Callable
base_types StringName[]

reload_scene_from_path(String)

Reloads the scene at the given path.

void reload_scene_from_path(String scene_filepath)

Parameters

scene_filepath String

restart_editor(bool)

Restarts the editor. This closes the editor and then opens the same project. If save is true, the project will be saved before restarting.

void restart_editor(bool save)

Parameters

save bool

save_all_scenes

Saves all opened scenes in the editor.

void save_all_scenes

save_scene

Saves the currently active scene. Returns either @GlobalScope.OK or @GlobalScope.ERR_CANT_CREATE.

int save_scene

save_scene_as(String, bool)

Saves the currently active scene as a file at path.

void save_scene_as(String path, bool with_preview)

Parameters

path String
with_preview bool

select_file(String)

Selects the file, with the path provided by file, in the FileSystem dock.

void select_file(String file)

Parameters

file String

set_current_feature_profile(String)

Selects and activates the specified feature profile with the given profile_name. Set profile_name to an empty string to reset to the default feature profile.

A feature profile can be created programmatically using the EditorFeatureProfile class.

Note: The feature profile that gets activated must be located in the feature_profiles directory, as a file with the .profile extension. If a profile could not be found, an error occurs. The editor configuration folder can be found by using get_config_dir.

void set_current_feature_profile(String profile_name)

Parameters

profile_name String

set_main_screen_editor(String)

Sets the editor's current main screen to the one specified in name. name must match the title of the tab in question exactly (e.g. 2D, 3D, Script, or AssetLib for default tabs).

void set_main_screen_editor(String name)

Parameters

name String

set_plugin_enabled(String, bool)

Sets the enabled status of a plugin. The plugin name is the same as its directory name.

void set_plugin_enabled(String plugin, bool enabled)

Parameters

plugin String
enabled bool

stop_playing_scene

Stops the scene that is currently playing.

void stop_playing_scene