Class EditorInterface
- Namespace
- Godot
- Assembly
- GodotSharpEditor.dll
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.
// In C# you can access it via the static Singleton property.
EditorSettings settings = EditorInterface.Singleton.GetEditorSettings();
public class EditorInterface : GodotObject, IDisposable
- Inheritance
-
EditorInterface
- Implements
- Inherited Members
Properties
DistractionFreeMode
If true
, enables distraction-free mode which hides side docks to increase the space available for the main view.
public bool DistractionFreeMode { get; set; }
Property Value
MovieMakerEnabled
If true
, the Movie Maker mode is enabled in the editor. See MovieWriter for more information.
public bool MovieMakerEnabled { get; set; }
Property Value
Singleton
public static EditorInterface Singleton { get; }
Property Value
Methods
EditNode(Node)
Edits the given Node. The node will be also selected if it's inside the scene tree.
public void EditNode(Node node)
Parameters
node
Node
EditResource(Resource)
Edits the given Resource. If the resource is a Script you can also edit it with EditScript(Script, int, int, bool) to specify the line and column position.
public void EditResource(Resource resource)
Parameters
resource
Resource
EditScript(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.
public void EditScript(Script script, int line = -1, int column = 0, bool grabFocus = true)
Parameters
GetBaseControl()
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.
public Control GetBaseControl()
Returns
GetCommandPalette()
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.
public EditorCommandPalette GetCommandPalette()
Returns
GetCurrentDirectory()
Returns the current directory being viewed in the FileSystemDock. If a file is selected, its base directory will be returned using String.get_base_dir
instead.
public string GetCurrentDirectory()
Returns
GetCurrentFeatureProfile()
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 LoadFromFile(string).
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 GetConfigDir().
public string GetCurrentFeatureProfile()
Returns
GetCurrentPath()
Returns the current path being viewed in the FileSystemDock.
public string GetCurrentPath()
Returns
GetEditedSceneRoot()
Returns the edited (current) scene's root Node.
public Node GetEditedSceneRoot()
Returns
GetEditorMainScreen()
Returns the editor control responsible for main screen plugins and tools. Use it with plugins that implement _HasMainScreen().
Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.
public VBoxContainer GetEditorMainScreen()
Returns
GetEditorPaths()
Returns the EditorPaths singleton.
public EditorPaths GetEditorPaths()
Returns
GetEditorScale()
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.
public float GetEditorScale()
Returns
GetEditorSettings()
Returns the editor's EditorSettings instance.
public EditorSettings GetEditorSettings()
Returns
GetEditorTheme()
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.
public Theme GetEditorTheme()
Returns
GetEditorViewport2D()
Returns the 2D editor SubViewport. It does not have a camera. Instead, the view transforms are done directly and can be accessed with GlobalCanvasTransform.
public SubViewport GetEditorViewport2D()
Returns
GetEditorViewport3D(int)
Returns the specified 3D editor SubViewport, from 0
to 3
. The viewport can be used to access the active editor cameras with GetCamera3D().
public SubViewport GetEditorViewport3D(int idx = 0)
Parameters
idx
int
Returns
GetFileSystemDock()
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.
public FileSystemDock GetFileSystemDock()
Returns
GetInspector()
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.
public EditorInspector GetInspector()
Returns
GetOpenScenes()
Returns an Array with the file paths of the currently opened scenes.
public string[] GetOpenScenes()
Returns
- string[]
GetPlayingScene()
Returns the name of the scene that is being played. If no scene is currently being played, returns an empty string.
public string GetPlayingScene()
Returns
GetResourceFilesystem()
Returns the editor's EditorFileSystem instance.
public EditorFileSystem GetResourceFilesystem()
Returns
GetResourcePreviewer()
Returns the editor's EditorResourcePreview instance.
public EditorResourcePreview GetResourcePreviewer()
Returns
GetScriptEditor()
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.
public ScriptEditor GetScriptEditor()
Returns
GetSelectedPaths()
Returns an array containing the paths of the currently selected files (and directories) in the FileSystemDock.
public string[] GetSelectedPaths()
Returns
- string[]
GetSelection()
Returns the editor's EditorSelection instance.
public EditorSelection GetSelection()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InspectObject(GodotObject, string, bool)
Shows the given property on the given object
in the editor's Inspector dock. If inspectorOnly
is true
, plugins will not attempt to edit object
.
public void InspectObject(GodotObject @object, string forProperty = "", bool inspectorOnly = false)
Parameters
object
GodotObjectforProperty
stringinspectorOnly
bool
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsPlayingScene()
Returns true
if a scene is currently being played, false
otherwise. Paused scenes are considered as being played.
public bool IsPlayingScene()
Returns
IsPluginEnabled(string)
Returns true
if the specified plugin
is enabled. The plugin name is the same as its directory name.
public bool IsPluginEnabled(string plugin)
Parameters
plugin
string
Returns
MakeMeshPreviews(Array<Mesh>, int)
public Array<Texture2D> MakeMeshPreviews(Array<Mesh> meshes, int previewSize)
Parameters
Returns
MarkSceneAsUnsaved()
Marks the current scene tab as unsaved.
public void MarkSceneAsUnsaved()
OpenSceneFromPath(string)
Opens the scene at the given path.
public void OpenSceneFromPath(string sceneFilepath)
Parameters
sceneFilepath
string
PlayCurrentScene()
Plays the currently active scene.
public void PlayCurrentScene()
PlayCustomScene(string)
Plays the scene specified by its filepath.
public void PlayCustomScene(string sceneFilepath)
Parameters
sceneFilepath
string
PlayMainScene()
Plays the main scene.
public void PlayMainScene()
PopupDialog(Window, Rect2I?)
Pops up the dialog
in the editor UI with PopupExclusive(Node, Rect2I?). The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool).
public void PopupDialog(Window dialog, Rect2I? rect = null)
Parameters
dialog
Windowrect
Rect2I?If the parameter is null, then the default value is
new Rect2I(new Vector2I(0, 0), new Vector2I(0, 0))
.
PopupDialogCentered(Window, Vector2I?)
Pops up the dialog
in the editor UI with PopupExclusiveCentered(Node, Vector2I?). The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool).
public void PopupDialogCentered(Window dialog, Vector2I? minsize = null)
Parameters
dialog
Windowminsize
Vector2I?If the parameter is null, then the default value is
new Vector2I(0, 0)
.
PopupDialogCenteredClamped(Window, Vector2I?, float)
Pops up the dialog
in the editor UI with PopupExclusiveCenteredClamped(Node, Vector2I?, float). The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool).
public void PopupDialogCenteredClamped(Window dialog, Vector2I? minsize = null, float fallbackRatio = 0.75)
Parameters
dialog
Windowminsize
Vector2I?If the parameter is null, then the default value is
new Vector2I(0, 0)
.fallbackRatio
float
PopupDialogCenteredRatio(Window, float)
Pops up the dialog
in the editor UI with PopupExclusiveCenteredRatio(Node, float). The dialog must have no current parent, otherwise the method fails.
See also SetUnparentWhenInvisible(bool).
public void PopupDialogCenteredRatio(Window dialog, float ratio = 0.8)
Parameters
ReloadSceneFromPath(string)
Reloads the scene at the given path.
public void ReloadSceneFromPath(string sceneFilepath)
Parameters
sceneFilepath
string
RestartEditor(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.
public void RestartEditor(bool save = true)
Parameters
save
bool
SaveAllScenes()
Saves all opened scenes in the editor.
public void SaveAllScenes()
SaveScene()
Saves the currently active scene. Returns either Ok or CantCreate.
public Error SaveScene()
Returns
SaveSceneAs(string, bool)
Saves the currently active scene as a file at path
.
public void SaveSceneAs(string path, bool withPreview = true)
Parameters
SelectFile(string)
Selects the file, with the path provided by file
, in the FileSystem dock.
public void SelectFile(string file)
Parameters
file
string
SetCurrentFeatureProfile(string)
Selects and activates the specified feature profile with the given profileName
. Set profileName
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 GetConfigDir().
public void SetCurrentFeatureProfile(string profileName)
Parameters
profileName
string
SetMainScreenEditor(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).
public void SetMainScreenEditor(string name)
Parameters
name
string
SetPluginEnabled(string, bool)
Sets the enabled status of a plugin. The plugin name is the same as its directory name.
public void SetPluginEnabled(string plugin, bool enabled)
Parameters
StopPlayingScene()
Stops the scene that is currently playing.
public void StopPlayingScene()