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.

EditorInterface

Eredita: Object

Interfaccia dell'editor Godot.

Descrizione

EditorInterface dà il controllo sulla finestra dell'editor di Godot. Permette di personalizzare la finestra, salvare e (ri)caricare scene, renderizzare le anteprime delle mesh, ispezionare e modificare le risorse e gli oggetti e fornisce l'accesso a EditorSettings, EditorFileSystem, EditorResourcePreview, ScriptEditor, alla viewport dell'editor e alle informazioni sulle scene.

Nota: Questa classe non dovrebbe essere istanziata direttamente. Invece, accedi al singleton direttamente tramite il suo nome.

var editor_settings = EditorInterface.get_editor_settings()

Proprietà

bool

distraction_free_mode

bool

movie_maker_enabled

Metodi

void

add_root_node(node: Node)

Error

close_scene()

void

edit_node(node: Node)

void

edit_resource(resource: Resource)

void

edit_script(script: Script, line: int = -1, column: int = 0, grab_focus: bool = true)

Control

get_base_control() const

EditorCommandPalette

get_command_palette() const

String

get_current_directory() const

String

get_current_feature_profile() const

String

get_current_path() const

Node

get_edited_scene_root() const

String

get_editor_language() const

VBoxContainer

get_editor_main_screen() const

EditorPaths

get_editor_paths() const

float

get_editor_scale() const

EditorSettings

get_editor_settings() const

Theme

get_editor_theme() const

EditorToaster

get_editor_toaster() const

EditorUndoRedoManager

get_editor_undo_redo() const

SubViewport

get_editor_viewport_2d() const

SubViewport

get_editor_viewport_3d(idx: int = 0) const

FileSystemDock

get_file_system_dock() const

EditorInspector

get_inspector() const

float

get_node_3d_rotate_snap() const

float

get_node_3d_scale_snap() const

float

get_node_3d_translate_snap() const

Array[Node]

get_open_scene_roots() const

PackedStringArray

get_open_scenes() const

String

get_playing_scene() const

EditorFileSystem

get_resource_filesystem() const

EditorResourcePreview

get_resource_previewer() const

ScriptEditor

get_script_editor() const

PackedStringArray

get_selected_paths() const

EditorSelection

get_selection() const

PackedStringArray

get_unsaved_scenes() const

void

inspect_object(object: Object, for_property: String = "", inspector_only: bool = false)

bool

is_multi_window_enabled() const

bool

is_node_3d_snap_enabled() const

bool

is_object_edited(object: Object) const

bool

is_playing_scene() const

bool

is_plugin_enabled(plugin: String) const

Array[Texture2D]

make_mesh_previews(meshes: Array[Mesh], preview_size: int)

void

mark_scene_as_unsaved()

void

open_scene_from_path(scene_filepath: String, set_inherited: bool = false)

void

play_current_scene()

void

play_custom_scene(scene_filepath: String)

void

play_main_scene()

void

popup_create_dialog(callback: Callable, base_type: StringName = "", current_type: String = "", dialog_title: String = "", type_blocklist: Array[StringName] = [])

void

popup_dialog(dialog: Window, rect: Rect2i = Rect2i(0, 0, 0, 0))

void

popup_dialog_centered(dialog: Window, minsize: Vector2i = Vector2i(0, 0))

void

popup_dialog_centered_clamped(dialog: Window, minsize: Vector2i = Vector2i(0, 0), fallback_ratio: float = 0.75)

void

popup_dialog_centered_ratio(dialog: Window, ratio: float = 0.8)

void

popup_method_selector(object: Object, callback: Callable, current_value: String = "")

void

popup_node_selector(callback: Callable, valid_types: Array[StringName] = [], current_value: Node = null)

void

popup_property_selector(object: Object, callback: Callable, type_filter: PackedInt32Array = PackedInt32Array(), current_value: String = "")

void

popup_quick_open(callback: Callable, base_types: Array[StringName] = [])

void

reload_scene_from_path(scene_filepath: String)

void

restart_editor(save: bool = true)

void

save_all_scenes()

Error

save_scene()

void

save_scene_as(path: String, with_preview: bool = true)

void

select_file(file: String)

void

set_current_feature_profile(profile_name: String)

void

set_main_screen_editor(name: String)

void

set_object_edited(object: Object, edited: bool)

void

set_plugin_enabled(plugin: String, enabled: bool)

void

stop_playing_scene()


Descrizioni delle proprietà

bool distraction_free_mode 🔗

  • void set_distraction_free_mode(value: bool)

  • bool is_distraction_free_mode_enabled()

Se true, abilita la modalità senza distrazioni che nasconde i pannelli laterali per aumentare lo spazio disponibile per la vista principale.


bool movie_maker_enabled 🔗

  • void set_movie_maker_enabled(value: bool)

  • bool is_movie_maker_enabled()

Se true, la modalità Movie Maker è abilitata nell'editor. Vedi MovieWriter per ulteriori informazioni.


Descrizioni dei metodi

void add_root_node(node: Node) 🔗

Rende node la radice della scena attualmente aperta. Funziona solo se la scena è vuota. Se node è un'istanza di scena, verrà creata una scena ereditaria.


Error close_scene() 🔗

Chiude la scena attualmente attiva, ignorando eventuali modifiche in sospeso nel processo. Restituisce @GlobalScope.OK in caso di successo oppure @GlobalScope.ERR_DOES_NOT_EXIST se non c'è alcuna scena da chiudere.


void edit_node(node: Node) 🔗

Modifica il Node specificato. Il nodo verrà anche selezionato se si trova all'interno dell'albero di scene.


void edit_resource(resource: Resource) 🔗

Modifica la Resource specificata. Se la risorsa è uno Script, puoi anche modificarla con edit_script() per specificare la posizione della riga e della colonna.


void edit_script(script: Script, line: int = -1, column: int = 0, grab_focus: bool = true) 🔗

Modifica lo Script specificato. È anche possibile specificare la riga e la colonna su cui aprire lo script. Lo script verrà aperto con l'editor configurato dall'utente per la lingua dello script, che potrebbe essere un editor esterno.


Control get_base_control() const 🔗

Restituisce il contenitore principale della finestra dell'editor di Godot. Ad esempio, puoi usarlo per recuperare la dimensione del contenitore e posizionare i tuoi controlli di conseguenza.

Attenzione: Rimuovere e liberare questo nodo renderà l'editor inutile e potrebbe causare un arresto anomalo.


EditorCommandPalette get_command_palette() const 🔗

Restituisce l'istanza di EditorCommandPalette dell'editor.

Attenzione: Rimuovere e liberare questo nodo renderà una parte dell'editor inutile e potrebbe causare un arresto anomalo.


String get_current_directory() const 🔗

Restituisce la cartella attualmente visualizzata nel FileSystemDock. Se viene selezionato un file, la sua cartella di base verrà restituita attraverso String.get_base_dir().


String get_current_feature_profile() const 🔗

Restituisce il nome del profilo di funzionalità attualmente attivo. Se il profilo predefinito è attualmente attivo, viene restituita una stringa vuota.

Per ottenere un riferimento all'EditorFeatureProfile, è necessario caricare il profilo di funzionalità attraverso EditorFeatureProfile.load_from_file().

Nota: I profili di funzionalità creati tramite l'interfaccia utente sono caricati dalla cartella feature_profiles, come file con estensione .profile. È possibile ricavare la cartella di configurazione dell'editor tramite EditorPaths.get_config_dir().


String get_current_path() const 🔗

Restituisce il percorso attualmente visualizzato nel FileSystemDock.


Node get_edited_scene_root() const 🔗

Restituisce il Node radice della scena in fase di modifica (attuale).


String get_editor_language() const 🔗

Returns the language currently used for the editor interface.


VBoxContainer get_editor_main_screen() const 🔗

Restituisce il controllo dell'editor responsabile dei plugin e degli strumenti della schermata principale. Utilizzalo con le estensioni che implementano EditorPlugin._has_main_screen().

Nota: Questo nodo è un VBoxContainer, il che significa che se si aggiunge un figlio Control ad esso, è necessario impostare il Control.size_flags_vertical del figlio su Control.SIZE_EXPAND_FILL per fargli usare tutto lo spazio disponibile.

Attenzione: Rimuovere e liberare questo nodo renderà una parte dell'editor inutile e potrebbe causare un arresto anomalo.


EditorPaths get_editor_paths() const 🔗

Restituisce il singleton EditorPaths.


float get_editor_scale() 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 EditorSettings.interface/editor/appearance/display_scale and EditorSettings.interface/editor/appearance/custom_display_scale settings. The editor must be restarted for changes to be properly applied.


EditorSettings get_editor_settings() const 🔗

Restituisce l'istanza di EditorSettings dell'editor.


Theme get_editor_theme() const 🔗

Restituisce il Theme dell'editor.

Nota: Quando si crea un'interfaccia utente dell'editor personalizzata, è preferibile accedere agli elementi del tema direttamente dai nodi della GUI attraverso i metodi get_theme_*.


EditorToaster get_editor_toaster() const 🔗

Restituisce l'EditorToaster dell'editor.


EditorUndoRedoManager get_editor_undo_redo() const 🔗

Restituisce l'EditorUndoRedoManager dell'editor.


SubViewport get_editor_viewport_2d() const 🔗

Restituisce la SubViewport dell'editor 2D. Non ha una telecamera. Invece, le trasformazioni della vista vengono effettuate direttamente e sono accessibili con Viewport.global_canvas_transform.


SubViewport get_editor_viewport_3d(idx: int = 0) const 🔗

Restituisce la SubViewport dell'editor 3D specificata, da 0 a 3. La viewport può essere utilizzata per accedere alle telecamere dell'editor attivo con Viewport.get_camera_3d().


FileSystemDock get_file_system_dock() const 🔗

Restituisce l'istanza FileSystemDock dell'editor.

Attenzione: Rimuovere e liberare questo nodo renderà inutile una parte dell'editor e potrebbe causare un arresto anomalo.


EditorInspector get_inspector() const 🔗

Restituisce l'istanza EditorInspector dell'editor.

Attenzione: Rimuovere e liberare questo nodo renderà inutile una parte dell'editor e potrebbe causare un arresto anomalo.


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 🔗

Restituisce un array con riferimenti ai nodi radice delle scene attualmente aperte.


PackedStringArray get_open_scenes() const 🔗

Restituisce un array con i percorsi dei file delle scene attualmente aperte.


String get_playing_scene() const 🔗

Restituisce il nome della scena che è in riproduzione. Se nessuna scena è attualmente in riproduzione, restituisce una stringa vuota.


EditorFileSystem get_resource_filesystem() const 🔗

Restituisce l'istanza EditorFileSystem dell'editor.


EditorResourcePreview get_resource_previewer() const 🔗

Restituisce l'istanza EditorResourcePreview dell'editor.


ScriptEditor get_script_editor() const 🔗

Restituisce l'istanza ScriptEditor dell'editor.

Attenzione: Rimuovere e liberare questo nodo renderà inutile una parte dell'editor e potrebbe causare un arresto anomalo.


PackedStringArray get_selected_paths() const 🔗

Restituisce un array contenente i percorsi dei file (e cartelle) attualmente selezionati nel FileSystemDock.


EditorSelection get_selection() const 🔗

Restituisce l'istanza EditorSelection dell'editor.


PackedStringArray get_unsaved_scenes() const 🔗

Returns an array of file paths of currently unsaved scenes.


void inspect_object(object: Object, for_property: String = "", inspector_only: bool = false) 🔗

Mostra la proprietà specificata sull'oggetto object nel pannello dell'Ispettore dell'editor. Se inspector_only è true, i plugin non tenteranno di modificare 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:


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 🔗

Restituisce true se una scena è attualmente in riproduzione, altrimenti false. Le scene in pausa sono considerate in riproduzione.


bool is_plugin_enabled(plugin: String) const 🔗

Restituisce true se l'estensione plugin è abilitata. Il nome dell'estensione è la stessa della sua cartella.


Array[Texture2D] make_mesh_previews(meshes: Array[Mesh], preview_size: int) 🔗

Restituisce le anteprime della mesh renderizzate alla dimensione specificata come un Array di Texture2D.


void mark_scene_as_unsaved() 🔗

Contrassegna la scheda della scena attuale come non salvata.


void open_scene_from_path(scene_filepath: String, set_inherited: bool = false) 🔗

Apre la scena al percorso specificato. Se set_inherited è true, crea una nuova scena ereditata.


void play_current_scene() 🔗

Riproduce la scena attualmente attiva.


void play_custom_scene(scene_filepath: String) 🔗

Riproduce la scena specificata dal suo percorso file.


void play_main_scene() 🔗

Riproduce la scena principale.


void popup_create_dialog(callback: Callable, base_type: StringName = "", current_type: String = "", dialog_title: String = "", type_blocklist: Array[StringName] = []) 🔗

Sperimentale: Questo metodo potrebbe essere cambiato o rimosso in versioni future.

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)) 🔗

Apre la finestra dialog nell'interfaccia utente dell'editor con Window.popup_exclusive(). La finestra di dialogo non deve avere un genitore attuale, altrimenti il metodo fallisce.

Vedi anche Window.set_unparent_when_invisible().


void popup_dialog_centered(dialog: Window, minsize: Vector2i = Vector2i(0, 0)) 🔗

Apre la finestra dialog nell'interfaccia utente dell'editor con Window.popup_exclusive_centered(). La finestra di dialogo non deve avere un genitore attuale, altrimenti il metodo fallisce.

Vedi anche Window.set_unparent_when_invisible().


void popup_dialog_centered_clamped(dialog: Window, minsize: Vector2i = Vector2i(0, 0), fallback_ratio: float = 0.75) 🔗

Apre la finestra dialog nell'interfaccia utente dell'editor con Window.popup_exclusive_centered_clamped(). La finestra di dialogo non deve avere un genitore attuale, altrimenti il metodo fallisce.

Vedi anche Window.set_unparent_when_invisible().


void popup_dialog_centered_ratio(dialog: Window, ratio: float = 0.8) 🔗

Apre la finestra dialog nell'interfaccia utente dell'editor con Window.popup_exclusive_centered_ratio(). La finestra di dialogo non deve avere un genitore attuale, altrimenti il metodo fallisce.

Vedi anche Window.set_unparent_when_invisible().


void popup_method_selector(object: Object, callback: Callable, current_value: String = "") 🔗

Apre una finestra di dialogo dell'editor per selezionare un metodo da object. Il callback deve accettare un singolo argomento di tipo String che conterrà il nome del metodo selezionato o sarà vuoto se la finestra di dialogo viene chiusa. Se viene fornito current_value, il metodo sarà selezionato automaticamente nell'elenco dei metodi, se esiste.


void popup_node_selector(callback: Callable, valid_types: Array[StringName] = [], current_value: Node = null) 🔗

Apre una finestra di dialogo dell'editor per selezionare un Node dalla scena modificata. Il callback deve accettare un singolo argomento di tipo NodePath. Viene chiamato sul NodePath selezionato o sul percorso vuoto ^"" se la finestra di dialogo viene annullata. Se valid_types viene fornito, la finestra di dialogo mostrerà solo i nodi che corrispondono a uno dei tipi di nodo elencati. Se viene fornito current_value, il nodo verrà selezionato automaticamente nell'albero, se esiste.

Esempio: Visualizza la finestra di dialogo per selezionare un nodo non appena questo nodo viene aggiunto all'albero per la prima volta:

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("selezione nodo annullata")
    else:
        print("selezionato ", node_path)

void popup_property_selector(object: Object, callback: Callable, type_filter: PackedInt32Array = PackedInt32Array(), current_value: String = "") 🔗

Apre una finestra di dialogo dell'editor per selezionare le proprietà da object. Il callback deve accettare un singolo argomento di tipo NodePath. Viene chiamato sul percorso della proprietà selezionata (vedi NodePath.get_as_property_path()) o sul percorso vuoto ^"" se la finestra di dialogo viene annullata. Se type_filter viene fornito, la finestra di dialogo mostrerà solo le proprietà che corrispondono a uno dei valori di Variant.Type elencati. Se viene fornito current_value, la proprietà verrà selezionata automaticamente nell'elenco delle proprietà, se esiste.

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("selezione proprietà annullata")
    else:
        print("selezionata ", property_path)

void popup_quick_open(callback: Callable, base_types: Array[StringName] = []) 🔗

Apre una finestra di dialogo dell'editor per selezionare rapidamente un file risorsa. Il callback deve accettare un singolo argomento di tipo String che conterrà il percorso della risorsa selezionata o sarà vuoto se la finestra di dialogo viene chiusa. Se viene fornito base_types, la finestra di dialogo mostrerà solo le risorse che corrispondono a questi tipi. Sono supportati solo i tipi derivanti da Resource.


void reload_scene_from_path(scene_filepath: String) 🔗

Reloads the scene at the given path. Fails if the scene is not open.


void restart_editor(save: bool = true) 🔗

Riavvia l'editor. Questo chiude l'editor e poi apre lo stesso progetto. Se save è true, il progetto verrà salvato prima di riavviare.


void save_all_scenes() 🔗

Salva tutte le scene aperte nell'editor.


Error save_scene() 🔗

Salva la scena attualmente attiva. Restituisce @GlobalScope.OK o @GlobalScope.ERR_CANT_CREATE.


void save_scene_as(path: String, with_preview: bool = true) 🔗

Salva la scena attualmente attiva come file nel percorso path.


void select_file(file: String) 🔗

Seleziona il file, con il percorso fornito da file, nel pannello del FileSystem.


void set_current_feature_profile(profile_name: String) 🔗

Seleziona e attiva il profilo di funzionalità specificato con il nome del profilo profile_name specificato. Imposta profile_name su una stringa vuota per ripristinare il profilo di funzionalità predefinito.

Un profilo di funzionalità può essere creato in codice usando la classe EditorFeatureProfile.

Nota: Il profilo di funzionalità che viene attivato deve trovarsi nella cartella feature_profiles, come file con estensione .profile. Se non è possibile trovare un profilo, si verifica un errore. La cartella di configurazione dell'editor può essere trovata tramite EditorPaths.get_config_dir().


void set_main_screen_editor(name: String) 🔗

Imposta la schermata principale attuale dell'editor su quella specificata in name. name deve corrispondere esattamente al titolo della scheda in questione (ad esempio 2D, 3D, Script, Gioco o Asset Store per le schede predefinite).


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) 🔗

Imposta lo stato d'attivazione di un'estensione. Il nome dell'estensione è lo stesso del nome della sua cartella.


void stop_playing_scene() 🔗

Interrompe la scena attualmente in riproduzione.