class_editorsettings.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the EditorSettings.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_EditorSettings:
  6. EditorSettings
  7. ==============
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. Object that holds the project-independent editor settings.
  10. Description
  11. -----------
  12. Object that holds the project-independent editor settings. These settings are generally visible in the **Editor > Editor Settings** menu.
  13. Property names use slash delimiters to distinguish sections. Setting values can be of any :ref:`Variant<class_Variant>` type. It's recommended to use ``snake_case`` for editor settings to be consistent with the Godot editor itself.
  14. Accessing the settings can be done using the following methods, such as:
  15. .. tabs::
  16. .. code-tab:: gdscript
  17. var settings = EditorInterface.get_editor_settings()
  18. # `settings.set("some/property", 10)` also works as this class overrides `_set()` internally.
  19. settings.set_setting("some/property", 10)
  20. # `settings.get("some/property")` also works as this class overrides `_get()` internally.
  21. settings.get_setting("some/property")
  22. var list_of_settings = settings.get_property_list()
  23. .. code-tab:: csharp
  24. EditorSettings settings = GetEditorInterface().GetEditorSettings();
  25. // `settings.set("some/property", value)` also works as this class overrides `_set()` internally.
  26. settings.SetSetting("some/property", Value);
  27. // `settings.get("some/property", value)` also works as this class overrides `_get()` internally.
  28. settings.GetSetting("some/property");
  29. Godot.Collections.Array listOfSettings = settings.GetPropertyList();
  30. \ **Note:** This class shouldn't be instantiated directly. Instead, access the singleton using :ref:`EditorInterface.get_editor_settings<class_EditorInterface_method_get_editor_settings>`.
  31. Methods
  32. -------
  33. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`add_property_info<class_EditorSettings_method_add_property_info>` **(** :ref:`Dictionary<class_Dictionary>` info **)** |
  35. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`check_changed_settings_in_group<class_EditorSettings_method_check_changed_settings_in_group>` **(** :ref:`String<class_String>` setting_prefix **)** |const| |
  37. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`erase<class_EditorSettings_method_erase>` **(** :ref:`String<class_String>` property **)** |
  39. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Array<class_Array>` | :ref:`get_changed_settings<class_EditorSettings_method_get_changed_settings>` **(** **)** |const| |
  41. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_favorites<class_EditorSettings_method_get_favorites>` **(** **)** |const| |
  43. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Variant<class_Variant>` | :ref:`get_project_metadata<class_EditorSettings_method_get_project_metadata>` **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` default=null **)** |const| |
  45. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`String<class_String>` | :ref:`get_project_settings_dir<class_EditorSettings_method_get_project_settings_dir>` **(** **)** |const| |
  47. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_recent_dirs<class_EditorSettings_method_get_recent_dirs>` **(** **)** |const| |
  49. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Variant<class_Variant>` | :ref:`get_setting<class_EditorSettings_method_get_setting>` **(** :ref:`String<class_String>` name **)** |const| |
  51. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`has_setting<class_EditorSettings_method_has_setting>` **(** :ref:`String<class_String>` name **)** |const| |
  53. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`mark_setting_changed<class_EditorSettings_method_mark_setting_changed>` **(** :ref:`String<class_String>` setting **)** |
  55. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`property_can_revert<class_EditorSettings_method_property_can_revert>` **(** :ref:`String<class_String>` name **)** |
  57. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Variant<class_Variant>` | :ref:`property_get_revert<class_EditorSettings_method_property_get_revert>` **(** :ref:`String<class_String>` name **)** |
  59. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_builtin_action_override<class_EditorSettings_method_set_builtin_action_override>` **(** :ref:`String<class_String>` name, :ref:`Array<class_Array>` actions_list **)** |
  61. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_favorites<class_EditorSettings_method_set_favorites>` **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)** |
  63. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`set_initial_value<class_EditorSettings_method_set_initial_value>` **(** :ref:`StringName<class_StringName>` name, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` update_current **)** |
  65. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`set_project_metadata<class_EditorSettings_method_set_project_metadata>` **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` data **)** |
  67. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_recent_dirs<class_EditorSettings_method_set_recent_dirs>` **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)** |
  69. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_setting<class_EditorSettings_method_set_setting>` **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value **)** |
  71. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. Signals
  73. -------
  74. .. _class_EditorSettings_signal_settings_changed:
  75. - **settings_changed** **(** **)**
  76. Emitted after any editor setting has changed.
  77. Constants
  78. ---------
  79. .. _class_EditorSettings_constant_NOTIFICATION_EDITOR_SETTINGS_CHANGED:
  80. - **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.
  81. Method Descriptions
  82. -------------------
  83. .. _class_EditorSettings_method_add_property_info:
  84. - void **add_property_info** **(** :ref:`Dictionary<class_Dictionary>` info **)**
  85. Adds a custom property info to a property. The dictionary must contain:
  86. - ``name``: :ref:`String<class_String>` (the name of the property)
  87. - ``type``: :ref:`int<class_int>` (see :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>`)
  88. - optionally ``hint``: :ref:`int<class_int>` (see :ref:`PropertyHint<enum_@GlobalScope_PropertyHint>`) and ``hint_string``: :ref:`String<class_String>`\
  89. \ **Example:**\
  90. .. tabs::
  91. .. code-tab:: gdscript
  92. var settings = EditorInterface.get_editor_settings()
  93. settings.set("category/property_name", 0)
  94. var property_info = {
  95. "name": "category/property_name",
  96. "type": TYPE_INT,
  97. "hint": PROPERTY_HINT_ENUM,
  98. "hint_string": "one,two,three"
  99. }
  100. settings.add_property_info(property_info)
  101. .. code-tab:: csharp
  102. var settings = GetEditorInterface().GetEditorSettings();
  103. settings.Set("category/property_name", 0);
  104. var propertyInfo = new Godot.Collections.Dictionary
  105. {
  106. {"name", "category/propertyName"},
  107. {"type", Variant.Type.Int},
  108. {"hint", PropertyHint.Enum},
  109. {"hint_string", "one,two,three"}
  110. };
  111. settings.AddPropertyInfo(propertyInfo);
  112. ----
  113. .. _class_EditorSettings_method_check_changed_settings_in_group:
  114. - :ref:`bool<class_bool>` **check_changed_settings_in_group** **(** :ref:`String<class_String>` setting_prefix **)** |const|
  115. Checks if any settings with the prefix ``setting_prefix`` exist in the set of changed settings. See also :ref:`get_changed_settings<class_EditorSettings_method_get_changed_settings>`.
  116. ----
  117. .. _class_EditorSettings_method_erase:
  118. - void **erase** **(** :ref:`String<class_String>` property **)**
  119. Erases the setting whose name is specified by ``property``.
  120. ----
  121. .. _class_EditorSettings_method_get_changed_settings:
  122. - :ref:`Array<class_Array>` **get_changed_settings** **(** **)** |const|
  123. 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 :ref:`NOTIFICATION_EDITOR_SETTINGS_CHANGED<class_EditorSettings_constant_NOTIFICATION_EDITOR_SETTINGS_CHANGED>`
  124. ----
  125. .. _class_EditorSettings_method_get_favorites:
  126. - :ref:`PackedStringArray<class_PackedStringArray>` **get_favorites** **(** **)** |const|
  127. Returns the list of favorite files and directories for this project.
  128. ----
  129. .. _class_EditorSettings_method_get_project_metadata:
  130. - :ref:`Variant<class_Variant>` **get_project_metadata** **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` default=null **)** |const|
  131. Returns project-specific metadata for the ``section`` and ``key`` specified. If the metadata doesn't exist, ``default`` will be returned instead. See also :ref:`set_project_metadata<class_EditorSettings_method_set_project_metadata>`.
  132. ----
  133. .. _class_EditorSettings_method_get_project_settings_dir:
  134. - :ref:`String<class_String>` **get_project_settings_dir** **(** **)** |const|
  135. Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved.
  136. ----
  137. .. _class_EditorSettings_method_get_recent_dirs:
  138. - :ref:`PackedStringArray<class_PackedStringArray>` **get_recent_dirs** **(** **)** |const|
  139. Returns the list of recently visited folders in the file dialog for this project.
  140. ----
  141. .. _class_EditorSettings_method_get_setting:
  142. - :ref:`Variant<class_Variant>` **get_setting** **(** :ref:`String<class_String>` name **)** |const|
  143. Returns the value of the setting specified by ``name``. This is equivalent to using :ref:`Object.get<class_Object_method_get>` on the EditorSettings instance.
  144. ----
  145. .. _class_EditorSettings_method_has_setting:
  146. - :ref:`bool<class_bool>` **has_setting** **(** :ref:`String<class_String>` name **)** |const|
  147. Returns ``true`` if the setting specified by ``name`` exists, ``false`` otherwise.
  148. ----
  149. .. _class_EditorSettings_method_mark_setting_changed:
  150. - void **mark_setting_changed** **(** :ref:`String<class_String>` setting **)**
  151. Marks the passed editor setting as being changed, see :ref:`get_changed_settings<class_EditorSettings_method_get_changed_settings>`. Only settings which exist (see :ref:`has_setting<class_EditorSettings_method_has_setting>`) will be accepted.
  152. ----
  153. .. _class_EditorSettings_method_property_can_revert:
  154. - :ref:`bool<class_bool>` **property_can_revert** **(** :ref:`String<class_String>` name **)**
  155. 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.
  156. ----
  157. .. _class_EditorSettings_method_property_get_revert:
  158. - :ref:`Variant<class_Variant>` **property_get_revert** **(** :ref:`String<class_String>` name **)**
  159. 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.
  160. ----
  161. .. _class_EditorSettings_method_set_builtin_action_override:
  162. - void **set_builtin_action_override** **(** :ref:`String<class_String>` name, :ref:`Array<class_Array>` actions_list **)**
  163. ----
  164. .. _class_EditorSettings_method_set_favorites:
  165. - void **set_favorites** **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)**
  166. Sets the list of favorite files and directories for this project.
  167. ----
  168. .. _class_EditorSettings_method_set_initial_value:
  169. - void **set_initial_value** **(** :ref:`StringName<class_StringName>` name, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` update_current **)**
  170. 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.
  171. ----
  172. .. _class_EditorSettings_method_set_project_metadata:
  173. - void **set_project_metadata** **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` data **)**
  174. 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 :ref:`get_project_metadata<class_EditorSettings_method_get_project_metadata>`.
  175. ----
  176. .. _class_EditorSettings_method_set_recent_dirs:
  177. - void **set_recent_dirs** **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)**
  178. Sets the list of recently visited folders in the file dialog for this project.
  179. ----
  180. .. _class_EditorSettings_method_set_setting:
  181. - void **set_setting** **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value **)**
  182. Sets the ``value`` of the setting specified by ``name``. This is equivalent to using :ref:`Object.set<class_Object_method_set>` on the EditorSettings instance.
  183. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  184. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  185. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  186. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  187. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  188. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`