EditorInterface
Hereda: Object
La interfaz del editor de Godot.
Descripción
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()
// In C# you can access it via the static Singleton property.
EditorSettings settings = EditorInterface.Singleton.GetEditorSettings();
Propiedades
Métodos
Descripciones de Propiedades
Si es true, permite el modo libre de distracción que oculta los muelles laterales para aumentar el espacio disponible para la vista principal.
If true, the Movie Maker mode is enabled in the editor. See MovieWriter for more information.
Descripciones de Métodos
void add_root_node(node: Node) 🔗
Convierte a node en la raíz de la escena actualmente abierta. Solo funciona si la escena está vacía. Si node es una instancia de escena, se creará una escena heredada.
Cierra la escena activa actualmente, descartando cualquier cambio pendiente en el proceso. Devuelve @GlobalScope.OK si tiene éxito o @GlobalScope.ERR_DOES_NOT_EXIST si no hay ninguna escena que cerrar.
Edita el Node dado. El nodo también se seleccionará si está dentro del árbol de la escena.
void edit_resource(resource: Resource) 🔗
Edita el Resource dado. Si el recurso es un Script también puedes editarlo con edit_script() para especificar la posición de la línea y la columna.
void edit_script(script: Script, line: int = -1, column: int = 0, grab_focus: bool = true) 🔗
Edita el Script dado. También se puede especificar la línea y la columna en la que se abrirá el script. El script se abrirá con el editor configurado por el usuario para el lenguaje del script, que puede ser un editor externo.
Control get_base_control() const 🔗
Devuelve el contenedor principal de la ventana del editor de Godot. Por ejemplo, puedes usarlo para recuperar el tamaño del contenedor y colocar tus controles según corresponda.
Advertencia: Eliminar y liberar este nodo hará que el editor sea inutilizable y puede provocar un fallo.
EditorCommandPalette get_command_palette() const 🔗
Devuelve la instancia EditorCommandPalette del editor.
Advertencia: Eliminar y liberar este nodo inutilizará una parte del editor y puede provocar un fallo.
String get_current_directory() const 🔗
Devuelve el directorio actual que se está viendo en FileSystemDock. Si se selecciona un archivo, se devolverá su directorio base utilizando String.get_base_dir() en su lugar.
String get_current_feature_profile() const 🔗
Devuelve el nombre del perfil de características activado actualmente. Si el perfil predeterminado está activo, se devuelve una string vacía en su lugar.
Para obtener una referencia al EditorFeatureProfile, debes cargar el perfil de características usando EditorFeatureProfile.load_from_file().
Nota: Los perfiles de características creados a través de la interfaz de usuario se cargan desde el directorio feature_profiles, como un archivo con la extensión .profile. La carpeta de configuración del editor se puede encontrar usando EditorPaths.get_config_dir().
String get_current_path() const 🔗
Devuelve la ruta actual que se está viendo en el FileSystemDock.
Node get_edited_scene_root() const 🔗
Devuelve la raíz de la escena editada (actual) Node.
String get_editor_language() const 🔗
Returns the language currently used for the editor interface.
VBoxContainer get_editor_main_screen() const 🔗
Devuelve el control del editor responsable de los plugins y herramientas de la pantalla principal. Úsalo con plugins que implementen EditorPlugin._has_main_screen().
Nota: Este nodo es un VBoxContainer, lo que significa que si añades un hijo Control a él, necesitas establecer el Control.size_flags_vertical del hijo a Control.SIZE_EXPAND_FILL para que use todo el espacio disponible.
Advertencia: Eliminar y liberar este nodo hará que una parte del editor sea inútil y puede provocar un fallo.
EditorPaths get_editor_paths() const 🔗
Devuelve el singleton EditorPaths.
float get_editor_scale() const 🔗
Devuelve la escala real de la UI del editor (1.0 siendo la escala al 100%). Esto se puede usar para ajustar la posición y las dimensiones de la UI añadida por los plugins.
Nota: Este valor se establece a través de los ajustes EditorSettings.interface/editor/display_scale y EditorSettings.interface/editor/custom_display_scale. El editor debe reiniciarse para que los cambios se apliquen correctamente.
EditorSettings get_editor_settings() const 🔗
Devuelve la instancia del editor EditorSettings.
Theme get_editor_theme() const 🔗
Devuelve el Theme del editor.
Nota: Al crear una interfaz de usuario de editor personalizada, prefiere acceder a los elementos del tema directamente desde tus nodos GUI usando los métodos get_theme_*.
EditorToaster get_editor_toaster() const 🔗
Devuelve el EditorToaster del editor.
EditorUndoRedoManager get_editor_undo_redo() const 🔗
Devuelve el EditorUndoRedoManager del editor.
SubViewport get_editor_viewport_2d() const 🔗
Devuelve el SubViewport del editor 2D. No tiene una cámara. En su lugar, las transformaciones de la vista se hacen directamente y se puede acceder a ellas con Viewport.global_canvas_transform.
SubViewport get_editor_viewport_3d(idx: int = 0) const 🔗
Devuelve el SubViewport del editor 3D especificado, de 0 a 3. El viewport puede ser usado para acceder a las cámaras del editor activo con Viewport.get_camera_3d().
FileSystemDock get_file_system_dock() const 🔗
Devuelve la instancia FileSystemDock del editor.
Advertencia: Eliminar y liberar este nodo hará que una parte del editor sea inútil y puede provocar un fallo.
EditorInspector get_inspector() const 🔗
Devuelve la instancia EditorInspector del editor.
Advertencia: Eliminar y liberar este nodo hará que una parte del editor sea inútil y puede provocar un fallo.
float get_node_3d_rotate_snap() const 🔗
Returns the amount of degrees the 3D editor's rotational snapping is set to.
float get_node_3d_scale_snap() const 🔗
Returns the amount of units the 3D editor's scale snapping is set to.
float get_node_3d_translate_snap() const 🔗
Returns the amount of units the 3D editor's translation snapping is set to.
Array[Node] get_open_scene_roots() const 🔗
Devuelve un array con referencias a los nodos raíz de las escenas abiertas actualmente.
PackedStringArray get_open_scenes() const 🔗
Devuelve un array con las rutas de archivo de las escenas abiertas actualmente.
String get_playing_scene() const 🔗
Devuelve el nombre de la escena que se está reproduciendo. Si no se está reproduciendo ninguna escena, devuelve una string vacía.
EditorFileSystem get_resource_filesystem() const 🔗
Devuelve la instancia del editor EditorFileSystem.
EditorResourcePreview get_resource_previewer() const 🔗
Devuelve la instancia del editor EditorResourcePreview.
ScriptEditor get_script_editor() const 🔗
Devuelve la instancia ScriptEditor del editor.
Advertencia: Eliminar y liberar este nodo hará que una parte del editor sea inútil y puede provocar un fallo.
PackedStringArray get_selected_paths() const 🔗
Devuelve un array que contiene las rutas de los archivos (y directorios) seleccionados actualmente en el FileSystemDock.
EditorSelection get_selection() const 🔗
Devuelve la instancia del editor EditorSelection.
void inspect_object(object: Object, for_property: String = "", inspector_only: bool = false) 🔗
Muestra la propiedad dada en el object dado en el dock Inspector del editor. Si inspector_only es true, los plugins no intentarán editar object.
bool is_multi_window_enabled() const 🔗
Returns true if multiple window support is enabled in the editor. Multiple window support is enabled if all of these statements are true:
EditorSettings.interface/editor/single_window_mode is
false.Viewport.gui_embed_subwindows is
false. This is forced totrueon platforms that don't support multiple windows such as Web, or when the--single-windowcommand line argument is used.
bool is_node_3d_snap_enabled() const 🔗
Returns true if the 3D editor currently has snapping mode enabled, and false otherwise.
bool is_object_edited(object: Object) const 🔗
Returns true if the object has been marked as edited through set_object_edited().
bool is_playing_scene() const 🔗
Devuelve true si se está reproduciendo una escena, false en caso contrario. Las escenas en pausa se consideran como si estuvieran siendo reproducidas.
bool is_plugin_enabled(plugin: String) const 🔗
Devuelve true si el plugin especificado está activado. El nombre del plugin es el mismo que el nombre de su directorio.
Array[Texture2D] make_mesh_previews(meshes: Array[Mesh], preview_size: int) 🔗
Devuelve las previsualizaciones de la malla renderizadas al tamaño dado como un Array de Texture2D.
void mark_scene_as_unsaved() 🔗
Marca la pestaña de la escena actual como no guardada.
void open_scene_from_path(scene_filepath: String, set_inherited: bool = false) 🔗
Abre la escena en la ruta dada. Si set_inherited es true, crea una nueva escena heredada.
void play_current_scene() 🔗
Reproduce la escena actualmente activa.
void play_custom_scene(scene_filepath: String) 🔗
Reproduce la escena especificada por su ruta de acceso.
void play_main_scene() 🔗
Reproduce la escena principal.
void popup_create_dialog(callback: Callable, base_type: StringName = "", current_type: String = "", dialog_title: String = "", type_blocklist: Array[StringName] = []) 🔗
Experimental: Este método podría ser modificado o eliminado en versiones futuras.
Pops up an editor dialog for creating an object.
The 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.
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_dialog(dialog: Window, rect: Rect2i = Rect2i(0, 0, 0, 0)) 🔗
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_centered(dialog: Window, minsize: Vector2i = Vector2i(0, 0)) 🔗
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_clamped(dialog: Window, minsize: Vector2i = Vector2i(0, 0), fallback_ratio: float = 0.75) 🔗
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_ratio(dialog: Window, ratio: float = 0.8) 🔗
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_method_selector(object: Object, callback: Callable, current_value: 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_node_selector(callback: Callable, valid_types: Array[StringName] = [], current_value: Node = null) 🔗
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_property_selector(object: Object, callback: Callable, type_filter: PackedInt32Array = PackedInt32Array(), current_value: 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 NodePath.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_quick_open(callback: Callable, base_types: Array[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 reload_scene_from_path(scene_filepath: String) 🔗
Recarga la escena de la ruta dada.
void restart_editor(save: bool = true) 🔗
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 save_all_scenes() 🔗
Guarda todas las escenas abiertas en el editor.
Saves the currently active scene. Returns either @GlobalScope.OK or @GlobalScope.ERR_CANT_CREATE.
void save_scene_as(path: String, with_preview: bool = true) 🔗
Saves the currently active scene as a file at path.
void select_file(file: String) 🔗
Selecciona el archivo, con la ruta proporcionada por file, en el dock del Sistema de archivos.
void set_current_feature_profile(profile_name: 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 EditorPaths.get_config_dir().
void set_main_screen_editor(name: String) 🔗
Establece la pantalla principal actual del editor a la especificada en name. name debe coincidir exactamente con el título de la pestaña en cuestión (p. ej. 2D, 3D, Script, Juego, o Librería de Assets para las pestañas predeterminadas).
void set_object_edited(object: Object, edited: bool) 🔗
If edited is true, the object is marked as edited.
Note: 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 true. Saving the scene, script, or resource resets the edited state by calling this method with false.
Note: 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.
void set_plugin_enabled(plugin: String, enabled: bool) 🔗
Establece el estado habilitado de un plugin. El nombre del plugin es el mismo que su nombre de directorio.
void stop_playing_scene() 🔗
Detiene la escena que se está reproduciendo actualmente.