GodotSharpEditor
s are automatically invoked whenever the user exports the project. Their most common use is to determine what files are being included in the exported project. For each plugin, is called at the beginning of the export process and then is called for each exported file.
To use , register it using the method first.
Virtual method to be overridden by the user. It is called when the export starts and provides all information about the export. features is the list of features for the export, is_debug is true for debug builds, path is the target path for the exported project. flags is only used when running a runnable profile, e.g. when using native run on Android.
Virtual method to be overridden by the user. Called when the export is finished.
Virtual method to be overridden by the user. Called for each exported file, providing arguments that can be used to identify the file. path is the path of the file, type is the represented by the file (e.g. ) and features is the list of features for the export.
Calling inside this callback will make the file not included in the export.
Adds a shared object or a directory containing only shared objects with the given tags and destination path.
Note: In case of macOS exports, those shared objects will be added to Frameworks directory of app bundle.
In case of a directory code-sign will error if you place non code object in directory.
Adds a static lib from the given path to the iOS project.
Adds a custom file to be exported. path is the virtual path that can be used to load the file, file is the binary data of the file. If remap is true, file will not be exported, but instead remapped to the given path.
Adds a static library (*.a) or dynamic library (*.dylib, *.framework) to Linking Phase in iOS's Xcode project.
Adds a dynamic library (*.dylib, *.framework) to Linking Phase in iOS's Xcode project and embeds it into resulting binary.
Note: For static libraries (*.a) works in same way as .
This method should not be used for System libraries as they are already present on the device.
Adds content for iOS Property List files.
Adds linker flags for the iOS export.
Adds an iOS bundle file from the given path to the exported project.
Adds a C++ code to the iOS export. The final code is created from the code appended by each active export plugin.
Adds file or directory matching path to PlugIns directory of macOS app bundle.
Note: This is useful only for macOS exports.
To be called inside . Skips the current file, so it's not included in the export.
An editor feature profile can be used to disable specific features of the Godot editor. When disabled, the features won't appear in the editor, which makes the editor less cluttered. This is useful in education settings to reduce confusion or when working in a team. For example, artists and level designers could use a feature profile that disables the script editor to avoid accidentally making changes to files they aren't supposed to edit.
To manage editor feature profiles visually, use Editor > Manage Feature Profiles... at the top of the editor window.
The 3D editor. If this feature is disabled, the 3D editor won't display but 3D nodes will still display in the Create New Node dialog.
The Script tab, which contains the script editor and class reference browser. If this feature is disabled, the Script tab won't display.
The AssetLib tab. If this feature is disabled, the AssetLib tab won't display.
Scene tree editing. If this feature is disabled, the Scene tree dock will still be visible but will be read-only.
The Node dock. If this feature is disabled, signals and groups won't be visible and modifiable from the editor.
The FileSystem dock. If this feature is disabled, the FileSystem dock won't be visible.
The Import dock. If this feature is disabled, the Import dock won't be visible.
Represents the size of the enum.
If disable is true, disables the class specified by class_name. When disabled, the class won't appear in the Create New Node dialog.
Returns true if the class specified by class_name is disabled. When disabled, the class won't appear in the Create New Node dialog.
If disable is true, disables editing for the class specified by class_name. When disabled, the class will still appear in the Create New Node dialog but the inspector will be read-only when selecting a node that extends the class.
Returns true if editing for the class specified by class_name is disabled. When disabled, the class will still appear in the Create New Node dialog but the inspector will be read-only when selecting a node that extends the class.
If disable is true, disables editing for property in the class specified by class_name. When a property is disabled, it won't appear in the inspector when selecting a node that extends the class specified by class_name.
Returns true if property is disabled in the class specified by class_name. When a property is disabled, it won't appear in the inspector when selecting a node that extends the class specified by class_name.
If disable is true, disables the editor feature specified in feature. When a feature is disabled, it will disappear from the editor entirely.
Returns true if the feature is disabled. When a feature is disabled, it will disappear from the editor entirely.
Returns the specified feature's human-readable name.
Saves the editor feature profile to a file in JSON format. It can then be imported using the feature profile manager's Import button or the method.
Loads an editor feature profile from a file. The file must follow the JSON format obtained by using the feature profile manager's Export button or the method.
The displays resources as thumbnails.
The displays resources as a list of filenames.
The can select only one file. Accepting the window will open the file.
The can select multiple files. Accepting the window will open all files.
The can select only one directory. Accepting the window will open the directory.
The can select a file or directory. Accepting the window will open it.
The can select only one file. Accepting the window will save the file.
The can only view res:// directory contents.
The can only view user:// directory contents.
The can view the entire local file system.
The location from which the user may select a file, including res://, user://, and the local file system.
The view format in which the displays resources to the user.
The purpose of the , which defines the allowed behaviors.
The currently occupied directory.
The currently selected file.
The file system path in the address bar.
If true, hidden files and directories will be visible in the .
If true, the will not warn the user before overwriting files.
Removes all filters except for "All Files (*)".
Adds a comma-delimited file extension filter option to the with an optional semi-colon-delimited label.
For example, "*.tscn, *.scn; Scenes" results in filter text "Scenes (*.tscn, *.scn)".
Returns the VBoxContainer used to display the file system.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Notify the that its view of the data is no longer accurate. Updates the view contents on next view update.
This object holds information of all resources in the filesystem, their types, etc.
Note: This class shouldn't be instantiated directly. Instead, access the singleton using .
Gets the root directory object.
Returns true if the filesystem is being scanned.
Returns the scan progress for 0 to 1 if the FS is being scanned.
Scan the filesystem for changes.
Check if the source of any imported resource changed.
Update a file information. Call this if an external program (not Godot) modified the file.
Returns a view into the filesystem at path.
Returns the resource type of the file, given the full path. This returns a string such as "Resource" or "GDScript", not a file extension such as ".gd".
Scans the script files and updates the list of custom class names.
A more generalized, low-level variation of the directory concept.
Returns the number of subdirectories in this directory.
Returns the subdirectory at index idx.
Returns the number of files in this directory.
Returns the name of the file at index idx.
Returns the path to the file at index idx.
Returns the resource type of the file at index idx. This returns a string such as "Resource" or "GDScript", not a file extension such as ".gd".
Returns the name of the script class defined in the file at index idx. If the file doesn't define a script class using the class_name syntax, this will return an empty string.
Returns the base class of the script class defined in the file at index idx. If the file doesn't define a script class using the class_name syntax, this will return an empty string.
Returns true if the file at index idx imported properly.
Returns the name of this directory.
Returns the path to this directory.
Returns the parent directory for this directory or null if called on a directory at res:// or user://.
Returns the index of the file with name name or -1 if not found.
Returns the index of the directory with name name or -1 if not found.
s provide a way to extend the editor's resource import functionality. Use them to import resources from custom files or to provide alternatives to the editor's existing importers.
EditorImportPlugins work by associating with specific file extensions and a resource type. See and . They may optionally specify some import presets that affect the import process. EditorImportPlugins are responsible for creating the resources and saving them in the .import directory (see ).
Below is an example EditorImportPlugin that imports a from a file with the extension ".special" or ".spec":
tool
extends EditorImportPlugin
func get_importer_name():
return "my.special.plugin"
func get_visible_name():
return "Special Mesh"
func get_recognized_extensions():
return ["special", "spec"]
func get_save_extension():
return "mesh"
func get_resource_type():
return "Mesh"
func get_preset_count():
return 1
func get_preset_name(i):
return "Default"
func get_import_options(i):
return [{"name": "my_option", "default_value": false}]
func import(source_file, save_path, options, platform_variants, gen_files):
var file = File.new()
if file.open(source_file, File.READ) != OK:
return FAILED
var mesh = Mesh.new()
# Fill the Mesh with data read in "file", left as an exercise to the reader
var filename = save_path + "." + get_save_extension()
return ResourceSaver.save(filename, mesh)
To use , register it using the method first.
Gets the options and default values for the preset at this index. Returns an Array of Dictionaries with the following keys: name, default_value, property_hint (optional), hint_string (optional), usage (optional).
Gets the order of this importer to be run when importing resources. Importers with lower import orders will be called first, and higher values will be called later. Use this to ensure the importer runs after the dependencies are already imported. The default import order is 0 unless overridden by a specific importer. See for some predefined values.
Gets the unique name of the importer.
This method can be overridden to hide specific import options if conditions are met. This is mainly useful for hiding options that depend on others if one of them is disabled. For example:
func get_option_visibility(option, options):
# Only show the lossy quality setting if the compression mode is set to "Lossy".
if option == "compress/lossy_quality" and options.has("compress/mode"):
return int(options["compress/mode"]) == COMPRESS_LOSSY
return true
Return true to make all options always visible.
Gets the number of initial presets defined by the plugin. Use to get the default options for the preset and to get the name of the preset.
Gets the name of the options preset at this index.
Gets the priority of this plugin for the recognized extension. Higher priority plugins will be preferred. The default priority is 1.0.
Gets the list of file extensions to associate with this loader (case-insensitive). e.g. ["obj"].
Gets the Godot resource type associated with this loader. e.g. "Mesh" or "Animation".
Gets the extension used to save this resource in the .import directory (see ).
Gets the name to display in the import window. You should choose this name as a continuation to "Import as", e.g. "Import as Special Mesh".
Imports source_file into save_path with the import options specified. The platform_variants and gen_files arrays will be modified by this function.
This method must be overridden to do the actual importing work. See this class' description for an example of overriding this method.
This is the control that implements property editing in the editor's Settings dialogs, the Inspector dock, etc. To get the used in the editor's Inspector dock, use .
will show properties in the same order as the array returned by .
If a property's name is path-like (i.e. if it contains forward slashes), will create nested sections for "directories" along the path. For example, if a property is named highlighting/gdscript/node_path_color, it will be shown as "Node Path Color" inside the "GDScript" section nested inside the "Highlighting" section.
If a property has @GlobalScope.PROPERTY_USAGE_GROUP usage, it will group subsequent properties whose name starts with the property's hint string. The group ends when a property does not start with that hint string or when a new group starts. An empty group name effectively ends the current group. will create a top-level section for each group. For example, if a property with group usage is named Collide With and its hint string is collide_with_, a subsequent collide_with_area property will be shown as "Area" inside the "Collide With" section.
Note: Unlike sections created from path-like property names, won't capitalize the name for sections created from groups. So properties with group usage usually use capitalized names instead of snake_cased names.
Refreshes the inspector.
Note: To save on CPU resources, calling this method will do nothing if the time specified in docks/property_editor/auto_refresh_interval editor setting hasn't passed yet since this method was last called. (By default, this interval is set to 0.3 seconds.)
allows adding custom property editors to .
When an object is edited, the function is called and must return true if the object type is supported.
If supported, the function will be called, allowing to place custom controls at the beginning of the class.
Subsequently, the and are called for every category and property. They offer the ability to add custom controls to the inspector too.
Finally, will be called.
On each of these calls, the "add" functions can be called.
To use , register it using the method first.
Returns true if this object can be handled by this plugin.
Called to allow adding controls at the beginning of the list.
Called to allow adding controls at the beginning of the category.
Called to allow adding controls at the end of the list.
Called to allow adding property specific editors to the inspector. Usually these inherit . Returning true removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one.
Adds a custom control, which is not necessarily a property editor.
Adds a property editor for an individual property. The editor control must extend .
Adds an editor that allows modifying multiple properties. The editor control must extend .
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 , , , , the editor viewport, and information about scenes.
Note: This class shouldn't be instantiated directly. Instead, access the singleton using .
If true, enables distraction-free mode which hides side docks to increase the space available for the main view.
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.
Returns the editor's instance.
Returns the editor's instance.
Returns the editor's instance.
Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.
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.
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.
Edits the given . If the resource is a you can also edit it with to specify the line and column position.
Edits the given . The node will be also selected if it's inside the scene tree.
Edits the given . 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.
Opens the scene at the given path.
Reloads the scene at the given path.
Plays the main scene.
Plays the currently active scene.
Plays the scene specified by its filepath.
Stops the scene that is currently playing.
Returns true if a scene is currently being played, false otherwise. Paused scenes are considered as being played.
Returns the name of the scene that is being played. If no scene is currently being played, returns an empty string.
Returns an with the file paths of the currently opened scenes.
Returns the edited (current) scene's root .
Returns the editor's instance.
Returns the editor's instance.
Returns the main editor control. Use this as a parent for main screens.
Note: This returns the main editor control containing the whole editor, not the 2D or 3D viewports specifically.
Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.
Returns mesh previews rendered at the given size as an of s.
Selects the file, with the path provided by file, in the FileSystem dock.
Returns the path of the directory currently selected in the . If a file is selected, its base directory will be returned using String.get_base_dir instead.
Returns the current path being viewed in the .
Returns the editor's instance.
Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.
Sets the enabled status of a plugin. The plugin name is the same as its directory name.
Returns true if the specified plugin is enabled. The plugin name is the same as its directory name.
Returns the editor's instance.
Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.
Saves the scene. Returns either OK or ERR_CANT_CREATE (see @GlobalScope constants).
Saves the scene as a file at path.
Sets the editor's current main screen to the one specified in name. name must match the text of the tab in question exactly (2D, 3D, Script, AssetLib).
Plugins are used by the editor to extend functionality. The most common types of plugins are those which edit a given node or resource type, import plugins and export plugins. See also to add functions to the editor.
Represents the size of the enum.
This method is called when the editor is about to save the project, switch to another tab, etc. It asks the plugin to apply any pending state changes to ensure consistency.
This is used, for example, in shader editors to let the plugin know that it must apply the shader code being written by the user to the object.
This method is called when the editor is about to run the project. The plugin can then perform required operations before the project runs.
This method must return a boolean. If this method returns false, the project will not run. The run is aborted immediately, so this also prevents all other plugins' methods from running.
Clear all the state and reset the object being edited to zero. This ensures your plugin does not keep editing a currently existing node, or a node from the wrong scene.
Called by the engine when the user disables the in the Plugin tab of the project settings window.
This function is used for plugins that edit specific object types (nodes or resources). It requests the editor to edit the given object.
Called by the engine when the user enables the in the Plugin tab of the project settings window.
Called by the engine when the 2D editor's viewport is updated. Use the overlay for drawing. You can update the viewport manually by calling .
func forward_canvas_draw_over_viewport(overlay):
# Draw a circle at cursor position.
overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.white)
func forward_canvas_gui_input(event):
if event is InputEventMouseMotion:
# Redraw viewport when cursor is moved.
update_overlays()
return true
return false
This method is the same as , except it draws on top of everything. Useful when you need an extra layer that shows over anything else.
You need to enable calling of this method by using .
Called when there is a root node in the current edited scene, is implemented and an happens in the 2D viewport. Intercepts the , if return true consumes the event, otherwise forwards event to other Editor classes. Example:
# Prevents the InputEvent to reach other Editor classes
func forward_canvas_gui_input(event):
var forward = true
return forward
Must return false in order to forward the to other Editor classes. Example:
# Consumes InputEventMouseMotion and forwards other InputEvent types
func forward_canvas_gui_input(event):
var forward = false
if event is InputEventMouseMotion:
forward = true
return forward
Called by the engine when the 3D editor's viewport is updated. Use the overlay for drawing. You can update the viewport manually by calling .
func forward_spatial_draw_over_viewport(overlay):
# Draw a circle at cursor position.
overlay.draw_circle(overlay.get_local_mouse_position(), 64)
func forward_spatial_gui_input(camera, event):
if event is InputEventMouseMotion:
# Redraw viewport when cursor is moved.
update_overlays()
return true
return false
This method is the same as , except it draws on top of everything. Useful when you need an extra layer that shows over anything else.
You need to enable calling of this method by using .
Called when there is a root node in the current edited scene, is implemented and an happens in the 3D viewport. Intercepts the , if return true consumes the event, otherwise forwards event to other Editor classes. Example:
# Prevents the InputEvent to reach other Editor classes
func forward_spatial_gui_input(camera, event):
var forward = true
return forward
Must return false in order to forward the to other Editor classes. Example:
# Consumes InputEventMouseMotion and forwards other InputEvent types
func forward_spatial_gui_input(camera, event):
var forward = false
if event is InputEventMouseMotion:
forward = true
return forward
This is for editors that edit script-based objects. You can return a list of breakpoints in the format (script:line), for example: res://path_to_script.gd:25.
Override this method in your plugin to return a in order to give it an icon.
For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons.
Ideally, the plugin icon should be white with a transparent background and 16x16 pixels in size.
func get_plugin_icon():
# You can use a custom icon:
return preload("res://addons/my_plugin/my_plugin_icon.svg")
# Or use a built-in icon:
return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons")
Override this method in your plugin to provide the name of the plugin when displayed in the Godot editor.
For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons.
Override this method to provide a state data you want to be saved, like view position, grid settings, folding, etc. This is used when saving the scene (so state is kept when opening it again) and for switching tabs (so state can be restored when the tab returns). This data is automatically saved for each scene in an editstate file in the editor metadata folder. If you want to store global (scene-independent) editor data for your plugin, you can use instead.
Use to restore your saved state.
Note: This method should not be used to save important settings that should persist with the project.
Note: You must implement for the state to be stored and restored correctly.
func get_state():
var state = {"zoom": zoom, "preferred_color": my_color}
return state
Override this method to provide the GUI layout of the plugin or any other data you want to be stored. This is used to save the project's editor layout when is called or the editor layout was changed (for example changing the position of a dock). The data is stored in the editor_layout.cfg file in the editor metadata directory.
Use to restore your saved layout.
func get_window_layout(configuration):
configuration.set_value("MyPlugin", "window_position", $Window.position)
configuration.set_value("MyPlugin", "icon_color", $Icon.modulate)
Implement this function if your plugin edits a specific type of object (Resource or Node). If you return true, then you will get the functions and called when the editor requests them. If you have declared the methods and these will be called too.
Returns true if this is a main screen editor plugin (it goes in the workspace selector together with 2D, 3D, Script and AssetLib).
This function will be called when the editor is requested to become visible. It is used for plugins that edit a specific object type.
Remember that you have to manage the visibility of all your editor controls manually.
This method is called after the editor saves the project or when it's closed. It asks the plugin to save edited external scenes/resources.
Restore the state saved by . This method is called when the current scene tab is changed in the editor.
Note: Your plugin must implement , otherwise it will not be recognized and this method will not be called.
func set_state(data):
zoom = data.get("zoom", 1.0)
preferred_color = data.get("my_color", Color.white)
Restore the plugin GUI layout and data saved by . This method is called for every plugin on editor startup. Use the provided configuration file to read your saved data.
func set_window_layout(configuration):
$Window.position = configuration.get_value("MyPlugin", "window_position", Vector2())
$Icon.modulate = configuration.get_value("MyPlugin", "icon_color", Color.white)
Adds a custom control to a container (see ). There are many locations where custom controls can be added in the editor UI.
Please remember that you have to manage the visibility of your custom controls yourself (and likely hide it after adding it).
When your plugin is deactivated, make sure to remove your custom control with and free it with .
Adds a control to the bottom panel (together with Output, Debug, Animation, etc). Returns a reference to the button added. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with and free it with .
Adds the control to a specific dock slot (see for options).
If the dock is repositioned and as long as the plugin is active, the editor will save the dock position on further sessions.
When your plugin is deactivated, make sure to remove your custom control with and free it with .
Removes the control from the dock. You have to manually the control.
Removes the control from the bottom panel. You have to manually the control.
Removes the control from the specified container. You have to manually the control.
Adds a custom menu item to Project > Tools as name that calls callback on an instance of handler with a parameter ud when user activates it.
Adds a custom submenu under Project > Tools > name. submenu should be an object of class . This submenu should be cleaned up using remove_tool_menu_item(name).
Removes a menu name from Project > Tools.
Adds a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed.
When given node or resource is selected, the base type will be instanced (ie, "Spatial", "Control", "Resource"), then the script will be loaded and set to this object.
You can use the virtual method to check if your custom object is being edited by checking the script or using the is keyword.
During run-time, this will be a simple object with a script so this function does not need to be called then.
Removes a custom type added by .
Adds a script at path to the Autoload list as name.
Removes an Autoload name from the list.
Updates the overlays of the 2D and 3D editor viewport. Causes methods , , and to be called.
Makes a specific item in the bottom panel visible.
Minimizes the bottom panel.
Gets the undo/redo object. Most actions in the editor can be undoable, so use this object to make sure this happens when it's worth it.
Queue save the project's editor layout.
Registers a new . Import plugins are used to import custom and unsupported assets as a custom type.
Note: If you want to import custom 3D asset formats use instead.
See for an example of how to register a plugin.
Removes an import plugin registered by .
Registers a new . Scene importers are used to import custom 3D asset formats as scenes.
Removes a scene importer registered by .
Registers a new . Export plugins are used to perform tasks when the project is being exported.
See for an example of how to register a plugin.
Removes an export plugin registered by .
Registers a new . Gizmo plugins are used to add custom gizmos to the 3D preview viewport for a .
See for an example of how to register a plugin.
Removes a gizmo plugin registered by .
Registers a new . Inspector plugins are used to extend and provide custom configuration tools for your object's properties.
Note: Always use to remove the registered when your is disabled to prevent leaks and an unexpected behavior.
const MyInspectorPlugin = preload("res://addons/your_addon/path/to/your/script.gd")
var inspector_plugin = MyInspectorPlugin.new()
func _enter_tree():
add_inspector_plugin(inspector_plugin)
func _exit_tree():
remove_inspector_plugin(inspector_plugin)
Removes an inspector plugin registered by
Use this method if you always want to receive inputs from 3D view screen inside . It might be especially usable if your plugin will want to use raycast in the scene.
Enables calling of for the 2D editor and for the 3D editor when their viewports are updated. You need to call this method only once and it will work permanently for this plugin.
Returns the object that gives you control over Godot editor's window and its functionalities.
Gets the Editor's dialog used for making scripts.
Note: Users can configure it before use.
Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.
This control allows property editing for one or multiple properties into . It is added via .
Set this property to change the label (if you want to show one).
Used by the inspector, set to true when the property is read-only.
Used by the inspector, set to true when the property is checkable.
Used by the inspector, set to true when the property is checked.
Used by the inspector, set to true when the property is drawn with the editor theme's warning color. This is used for editable children's properties.
Used by the inspector, set to true when the property can add keys for animation.
When this virtual function is called, you must update your editor.
Gets the edited property. If your editor is for a single property (added via ), then this will return the property.
Gets the edited object.
Must be implemented to provide a custom tooltip to the property editor.
If any of the controls added can gain keyboard focus, add it here. This ensures that focus will be restored if the inspector is refreshed.
Puts the editor control below the property label. The control must be previously added using .
If one or several properties have changed, this must be called. field is used in case your editor can modify fields separately (as an example, Vector3.x). The changing argument avoids the editor requesting this property to be refreshed (leave as false if unsure).
This node is used in the editor's Inspector dock to allow editing of type properties. It provides options for creating, loading, saving and converting resources. Can be used with to recreate the same behavior.
Note: This does not include any editor for the resource, as editing is controlled by the Inspector dock itself or sub-Inspectors.
The base type of allowed resource types. Can be a comma-separated list of several options.
The edited resource value.
If true, the value can be selected and edited.
If true, the main button with the resource preview works in the toggle mode. Use to manually set the state.
This virtual method can be implemented to handle context menu items not handled by default. See .
This virtual method is called when updating the context menu of . Implement this method to override the "New ..." items with your own options. menu_node is a reference to the node.
Note: Implement to handle these custom items.
Returns a list of all allowed types and subtypes corresponding to the . If the is empty, an empty list is returned.
Sets the toggle mode state for the main button. Works only if is set to true.
This object is used to generate previews for resources of files.
Note: This class shouldn't be instantiated directly. Instead, access the singleton using .
Queue a resource file located at path for preview. Once the preview is ready, the receiver's receiver_func will be called. The receiver_func must take the following four arguments: path, preview, thumbnail_preview, Variant userdata. userdata can be anything, and will be returned when receiver_func is called.
Note: If it was not possible to create the preview the receiver_func will still be called, but the preview will be null.
Queue the resource being edited for preview. Once the preview is ready, the receiver's receiver_func will be called. The receiver_func must take the following four arguments: path, preview, thumbnail_preview, Variant userdata. userdata can be anything, and will be returned when receiver_func is called.
Note: If it was not possible to create the preview the receiver_func will still be called, but the preview will be null.
Create an own, custom preview generator.
Removes a custom preview generator.
Check if the resource changed, if so, it will be invalidated and the corresponding signal emitted.
Custom code to generate previews. Please check file_dialog/thumbnail_size in to find out the right size to do previews at.
If this function returns true, the generator will call or for small previews as well.
By default, it returns false.
Generate a preview from a given resource with the specified size. This must always be implemented.
Returning an empty texture is an OK way to fail and let another generator take care.
Care must be taken because this function is always called from a thread (not the main thread).
Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call .
Returning an empty texture is an OK way to fail and let another generator take care.
Care must be taken because this function is always called from a thread (not the main thread).
If this function returns true, the generator will automatically generate the small previews from the normal preview texture generated by the methods or .
By default, it returns false.
Returns true if your generator supports the resource of type type.
allows to define an importer script for a third-party 3D format.
To use , register it using the method first.
This is an FBX 3D asset importer with full support for most FBX features.
If exporting a FBX scene from Autodesk Maya, use these FBX export settings:
- Smoothing Groups
- Smooth Mesh
- Triangluate (for meshes with blend shapes)
- Bake Animation
- Resample All
- Deformed Models
- Skins
- Blend Shapes
- Curve Filters
- Constant Key Reducer
- Auto Tangents Only
- *Do not check* Constraints (as it will break the file)
- Can check Embed Media (embeds textures into the exported FBX file)
- Note that when importing embedded media, the texture and mesh will be a single immutable file.
- You will have to re-export then re-import the FBX if the texture has changed.
- Units: Centimeters
- Up Axis: Y
- Binary format in FBX 2017
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Imported scenes can be automatically modified right after import by setting their Custom Script Import property to a tool script that inherits from this class.
The callback receives the imported scene's root node and returns the modified version of the scene. Usage example:
tool # Needed so it runs in editor
extends EditorScenePostImport
# This sample changes all node names
# Called right after the scene is imported and gets the root node
func post_import(scene):
# Change all node names to "modified_[oldnodename]"
iterate(scene)
return scene # Remember to return the imported scene
func iterate(node):
if node != null:
node.name = "modified_" + node.name
for child in node.get_children():
iterate(child)
Called after the scene was imported. This method must return the modified version of the scene.
Returns the resource folder the imported scene file is located in.
Returns the source file path which got imported (e.g. res://scene.dae).
Scripts extending this class and implementing its method can be executed from the Script Editor's File > Run menu option (or by pressing Ctrl+Shift+X) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using s instead.
Note: Extending scripts need to have tool mode enabled.
Example script:
tool
extends EditorScript
func _run():
print("Hello from the Godot Editor!")
Note: The script is run in the Editor context, which means the output is visible in the console window started with the Editor (stdout) instead of the usual Godot Output dock.
This method is executed by the Editor when File > Run is used.
Adds node as a child of the root node in the editor context.
Warning: The implementation of this method is currently disabled.
Returns the Editor's currently active scene.
Returns the singleton instance.
Similar to this node is used in the editor's Inspector dock, but only to edit the script property of a . Default options for creating new resources of all possible subtypes are replaced with dedicated buttons that open the "Attach Node Script" dialog. Can be used with to recreate the same behavior.
Note: You must set the for the custom context menu items to work.
The owner of the script property that holds the edited resource.
This object manages the SceneTree selection in the editor.
Note: This class shouldn't be instantiated directly. Instead, access the singleton using .
Clear the selection.
Adds a node to the selection.
Note: The newly selected node will not be automatically edited in the inspector. If you want to edit a node, use .
Removes a node from the selection.
Gets the list of selected nodes.
Gets the list of selected nodes, optimized for transform operations (i.e. moving them, rotating, etc). This list avoids situations where a node is selected and also child/grandchild.
Object that holds the project-independent editor settings. These settings are generally visible in the Editor > Editor Settings menu.
Property names use slash delimiters to distinguish sections. Setting values can be of any Variant type. It's recommended to use snake_case for editor settings to be consistent with the Godot editor itself.
Accessing the settings can be done using the following methods, such as:
# `settings.set("some/property", value)` also works as this class overrides `_set()` internally.
settings.set_setting("some/property",value)
# `settings.get("some/property", value)` also works as this class overrides `_get()` internally.
settings.get_setting("some/property")
var list_of_settings = settings.get_property_list()
Note: This class shouldn't be instantiated directly. Instead, access the singleton using .
Emitted after any editor setting has changed. It's used by various editor plugins to update their visuals on theme changes or logic on configuration changes.
Returns true if the setting specified by name exists, false otherwise.
Sets the value of the setting specified by name. This is equivalent to using on the EditorSettings instance.
Returns the value of the setting specified by name. This is equivalent to using on the EditorSettings instance.
Erases the setting whose name is specified by property.
Sets the initial value of the setting specified by name to value. This is used to provide a value for the Revert button in the Editor Settings. If update_current is true, the current value of the setting will be set to value as well.
Returns true if the setting specified by name can have its value reverted to the default value, false otherwise. When this method returns true, a Revert button will display next to the setting in the Editor Settings.
Returns the default value of the setting specified by name. This is the value that would be applied when clicking the Revert button in the Editor Settings.
Adds a custom property info to a property. The dictionary must contain:
- name: (the name of the property)
- type: (see )
- optionally hint: (see ) and hint_string:
Example:
editor_settings.set("category/property_name", 0)
var property_info = {
"name": "category/property_name",
"type": TYPE_INT,
"hint": PROPERTY_HINT_ENUM,
"hint_string": "one,two,three"
}
editor_settings.add_property_info(property_info)
Gets the global settings path for the engine. Inside this path, you can find some standard paths such as:
settings/tmp - Used for temporary storage of files
settings/templates - Where export templates are located
Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved.
Sets project-specific metadata with the section, key and data specified. This metadata is stored outside the project folder and therefore won't be checked into version control. See also .
Returns project-specific metadata for the section and key specified. If the metadata doesn't exist, default will be returned instead. See also .
Sets the list of favorite files and directories for this project.
Returns the list of favorite files and directories for this project.
Sets the list of recently visited folders in the file dialog for this project.
Returns the list of recently visited folders in the file dialog for this project.
Custom gizmo that is used for providing custom visualization and editing (handles) for 3D Spatial objects. See for more information.
Commit a handle being edited (handles must have been previously added by ).
If the cancel parameter is true, an option to restore the edited value to the original is provided.
Gets the name of an edited handle (handles must have been previously added by ).
Handles can be named for reference to the user when editing.
Gets actual value of a handle. This value can be anything and used for eventually undoing the motion when calling .
Returns true if the handle at index index is highlighted by being hovered with the mouse.
This function is called when the this gizmo refers to changes (the is called).
This function is used when the user drags a gizmo handle (previously added with ) in screen coordinates.
The is also provided so screen coordinates can be converted to raycasts.
Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this function during .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Adds a mesh to the gizmo with the specified billboard state, skeleton and material. If billboard is true, the mesh will rotate to always face the camera. Call this function during .
Adds the specified segments to the gizmo's collision shape for picking. Call this function during .
Adds collision triangles to the gizmo for picking. A can be generated from a regular too. Call this function during .
Adds an unscaled billboard for visualization. Call this function during .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Adds a list of handles (points) which can be used to deform the object being edited.
There are virtual functions which will be called upon editing of these handles. Call this function during .
Sets the reference node for the gizmo. node must inherit from .
Returns the Spatial node associated with this gizmo.
Returns the that owns this gizmo. It's useful to retrieve materials using .
Removes everything in the gizmo including meshes, collisions and handles.
Sets the gizmo's hidden state. If true, the gizmo will be hidden. If false, it will be shown.
allows you to define a new type of Gizmo. There are two main ways to do so: extending for the simpler gizmos, or creating a new type. See the tutorial in the documentation for more info.
To use , register it using the method first.
Override this method to define whether the gizmo can be hidden or not. Returns true if not overridden.
Override this method to commit gizmo handles. Called for this plugin's active gizmos.
Override this method to return a custom for the spatial nodes of your choice, return null for the rest of nodes. See also .
Override this method to provide gizmo's handle names. Called for this plugin's active gizmos.
Gets actual value of a handle from gizmo. Called for this plugin's active gizmos.
Override this method to provide the name that will appear in the gizmo visibility menu.
Override this method to set the gizmo's priority. Higher values correspond to higher priority. If a gizmo with higher priority conflicts with another gizmo, only the gizmo with higher priority will be used.
All built-in editor gizmos return a priority of -1. If not overridden, this method will return 0, which means custom gizmos will automatically override built-in gizmos.
Override this method to define which Spatial nodes have a gizmo from this plugin. Whenever a node is added to a scene this method is called, if it returns true the node gets a generic assigned and is added to this plugin's list of active gizmos.
Gets whether a handle is highlighted or not. Called for this plugin's active gizmos.
Override this method to define whether a Spatial with this gizmo should be selectable even when the gizmo is hidden.
Callback to redraw the provided gizmo. Called for this plugin's active gizmos.
Update the value of a handle after it has been updated. Called for this plugin's active gizmos.
Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with and used in and . Should not be overridden.
Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with and used in . Should not be overridden.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with and used in . Should not be overridden.
You can optionally provide a texture to use instead of the default icon.
Adds a new material to the internal material list for the plugin. It can then be accessed with . Should not be overridden.
Gets material from the internal list of materials. If an is provided, it will try to get the corresponding variant (selected and/or editable).
This node is used in the editor's Inspector dock to allow editing of numeric values. Can be used with to recreate the same behavior.
If true, the slider is hidden.
Defines the API that the editor uses to extract information from the underlying VCS. The implementation of this API is included in VCS plugins, which are scripts that inherit and are attached (on demand) to the singleton instance of . Instead of performing the task themselves, all the virtual functions listed below are calling the internally overridden functions in the VCS plugins to provide a plug-n-play experience. A custom VCS plugin is supposed to inherit from and override these virtual functions.
A new file has been added.
An earlier added file has been modified.
An earlier added file has been renamed.
An earlier added file has been deleted.
An earlier added file has been typechanged.
A file is left unmerged.
A commit is encountered from the commit area.
A file is encountered from the staged area.
A file is encountered from the unstaged area.
Checks out a branch_name in the VCS.
Commits the currently staged changes and applies the commit msg to the resulting commit.
Creates a new branch named branch_name in the VCS.
Creates a new remote destination with name remote_name and points it to remote_url. This can be both an HTTPS remote or an SSH remote.
Discards the changes made in file present at file_path.
Fetches new changes from the remote, but doesn't write changes to the current working directory. Equivalent to git fetch.
Gets an instance of an of s containing available branch names in the VCS.
Gets the current branch name defined in the VCS.
Returns an of items (see , , , and ), each containing information about a diff. If identifier is a file path, returns a file diff, and if it is a commit identifier, then returns a commit diff.
Returns an of items (see ), each containing a line diff between a file at file_path and the text which is passed in.
Returns an of items (see ), each containing the status data of every modified file in the project folder.
Returns an of items (see ), each containing the data for a past commit.
Returns an of s, each containing the name of a remote configured in the VCS.
Returns the name of the underlying VCS provider.
Initializes the VCS plugin when called from the editor. Returns whether or not the plugin was successfully initialized. A VCS project is initialized at project_path.
Pulls changes from the remote. This can give rise to merge conflicts.
Pushes changes to the remote. Optionally, if force is set to true, a force push will override the change history already present on the remote.
Remove a branch from the local VCS.
Remove a remote from the local VCS.
Set user credentials in the underlying VCS. username and password are used only during HTTPS authentication unless not already mentioned in the remote URL. ssh_public_key_path, ssh_private_key_path, and ssh_passphrase are only used during SSH authentication.
Shuts down VCS plugin instance. Called when the user either closes the editor or shuts down the VCS plugin through the editor UI.
Stages the file present at file_path to the staged area.
Unstages the file present at file_path from the staged area to the unstaged area.
Helper function to create a Dictionary for storing a line diff. new_line_no is the line number in the new file (can be -1 if the line is deleted). old_line_no is the line number in the old file (can be -1 if the line is added). content is the diff text. status is a single character string which stores the line origin.
Helper function to create a Dictionary for storing diff hunk data. old_start is the starting line number in old file. new_start is the starting line number in new file. old_lines is the number of lines in the old file. new_lines is the number of lines in the new file.
Helper function to create a Dictionary for storing old and new diff file paths.
Helper function to create a commit item. msg is the commit message of the commit. author is a single human-readable string containing all the author's details, e.g. the email and name configured in the VCS. id is the identifier of the commit, in whichever format your VCS may provide an identifier to commits. unix_timestamp is the UTC Unix timestamp of when the commit was created. offset_minutes is the timezone offset in minutes, recorded from the system timezone where the commit was created.
Helper function to create a Dictionary used by editor to read the status of a file.
Helper function to add an array of diff_hunks into a diff_file.
Helper function to add an array of line_diffs into a diff_hunk.
Pops up an error message in the edior.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
The creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling one of the methods.
func _ready():
dialog.config("Node", "res://new_node.gd") # For in-engine types
dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # For script types
dialog.popup_centered()
Prefills required fields to configure the ScriptCreateDialog for use.
Note: This class shouldn't be instantiated directly. Instead, access the singleton using .
Goes to the specified line in the current script.
Returns a that is currently active in editor.
Returns an array with all objects which are currently open in editor.
Opens the script create dialog. The script will extend base_name. The file extension can be omitted from base_path. It will be added based on the selected scripting language.
Reload all currently opened scripts from disk in case the file contents are newer.
Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the category as the parameter.
Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed.