class_editorsettings.rst 20 KB

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