EditorSettings¶
Inherits: Resource < RefCounted < Object
Object that holds the project-independent editor settings.
Description¶
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:
var settings = EditorInterface.get_editor_settings()
# `settings.set("some/property", 10)` also works as this class overrides `_set()` internally.
settings.set_setting("some/property", 10)
# `settings.get("some/property")` also works as this class overrides `_get()` internally.
settings.get_setting("some/property")
var list_of_settings = settings.get_property_list()
EditorSettings settings = GetEditorInterface().GetEditorSettings();
// `settings.set("some/property", value)` also works as this class overrides `_set()` internally.
settings.SetSetting("some/property", Value);
// `settings.get("some/property", value)` also works as this class overrides `_get()` internally.
settings.GetSetting("some/property");
Godot.Collections.Array listOfSettings = settings.GetPropertyList();
Note: This class shouldn't be instantiated directly. Instead, access the singleton using EditorInterface.get_editor_settings.
Methods¶
void |
add_property_info ( Dictionary info ) |
check_changed_settings_in_group ( String setting_prefix ) const |
|
void |
|
get_changed_settings ( ) const |
|
get_favorites ( ) const |
|
get_project_metadata ( String section, String key, Variant default=null ) const |
|
get_project_settings_dir ( ) const |
|
get_recent_dirs ( ) const |
|
get_setting ( String name ) const |
|
has_setting ( String name ) const |
|
void |
mark_setting_changed ( String setting ) |
property_can_revert ( String name ) |
|
property_get_revert ( String name ) |
|
void |
set_builtin_action_override ( String name, Array actions_list ) |
void |
set_favorites ( PackedStringArray dirs ) |
void |
set_initial_value ( StringName name, Variant value, bool update_current ) |
void |
set_project_metadata ( String section, String key, Variant data ) |
void |
set_recent_dirs ( PackedStringArray dirs ) |
void |
set_setting ( String name, Variant value ) |
Signals¶
settings_changed ( )
Emitted after any editor setting has changed.
Constants¶
NOTIFICATION_EDITOR_SETTINGS_CHANGED = 10000 --- 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.
Method Descriptions¶
void add_property_info ( Dictionary info )
Adds a custom property info to a property. The dictionary must contain:
name
: String (the name of the property)type
: int (see Variant.Type)optionally
hint
: int (see PropertyHint) andhint_string
: String
Example:
var settings = EditorInterface.get_editor_settings()
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"
}
settings.add_property_info(property_info)
var settings = GetEditorInterface().GetEditorSettings();
settings.Set("category/property_name", 0);
var propertyInfo = new Godot.Collections.Dictionary
{
{"name", "category/propertyName"},
{"type", Variant.Type.Int},
{"hint", PropertyHint.Enum},
{"hint_string", "one,two,three"}
};
settings.AddPropertyInfo(propertyInfo);
Checks if any settings with the prefix setting_prefix
exist in the set of changed settings. See also get_changed_settings.
void erase ( String property )
Erases the setting whose name is specified by property
.
Array get_changed_settings ( ) const
Gets an array of the settings which have been changed since the last save. Note that internally changed_settings
is cleared after a successful save, so generally the most appropriate place to use this method is when processing NOTIFICATION_EDITOR_SETTINGS_CHANGED
PackedStringArray get_favorites ( ) const
Returns the list of favorite files and directories for this project.
Returns project-specific metadata for the section
and key
specified. If the metadata doesn't exist, default
will be returned instead. See also set_project_metadata.
String get_project_settings_dir ( ) const
Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved.
PackedStringArray get_recent_dirs ( ) const
Returns the list of recently visited folders in the file dialog for this project.
Returns the value of the setting specified by name
. This is equivalent to using Object.get on the EditorSettings instance.
Returns true
if the setting specified by name
exists, false
otherwise.
void mark_setting_changed ( String setting )
Marks the passed editor setting as being changed, see get_changed_settings. Only settings which exist (see has_setting) will be accepted.
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.
void set_favorites ( PackedStringArray dirs )
Sets the list of favorite files and directories for this project.
void set_initial_value ( StringName name, Variant value, bool update_current )
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.
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 get_project_metadata.
void set_recent_dirs ( PackedStringArray dirs )
Sets the list of recently visited folders in the file dialog for this project.
Sets the value
of the setting specified by name
. This is equivalent to using Object.set on the EditorSettings instance.