class_editorsettings.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. | void | :ref:`erase<class_EditorSettings_method_erase>` **(** :ref:`String<class_String>` property **)** |
  37. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_favorites<class_EditorSettings_method_get_favorites>` **(** **)** |const| |
  39. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :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| |
  41. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`String<class_String>` | :ref:`get_project_settings_dir<class_EditorSettings_method_get_project_settings_dir>` **(** **)** |const| |
  43. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_recent_dirs<class_EditorSettings_method_get_recent_dirs>` **(** **)** |const| |
  45. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Variant<class_Variant>` | :ref:`get_setting<class_EditorSettings_method_get_setting>` **(** :ref:`String<class_String>` name **)** |const| |
  47. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`has_setting<class_EditorSettings_method_has_setting>` **(** :ref:`String<class_String>` name **)** |const| |
  49. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`property_can_revert<class_EditorSettings_method_property_can_revert>` **(** :ref:`String<class_String>` name **)** |
  51. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Variant<class_Variant>` | :ref:`property_get_revert<class_EditorSettings_method_property_get_revert>` **(** :ref:`String<class_String>` name **)** |
  53. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_builtin_action_override<class_EditorSettings_method_set_builtin_action_override>` **(** :ref:`String<class_String>` name, :ref:`Array<class_Array>` actions_list **)** |
  55. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_favorites<class_EditorSettings_method_set_favorites>` **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)** |
  57. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | 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 **)** |
  59. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | 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 **)** |
  61. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_recent_dirs<class_EditorSettings_method_set_recent_dirs>` **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)** |
  63. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`set_setting<class_EditorSettings_method_set_setting>` **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value **)** |
  65. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. Signals
  67. -------
  68. .. _class_EditorSettings_signal_settings_changed:
  69. - **settings_changed** **(** **)**
  70. Emitted after any editor setting has changed.
  71. Constants
  72. ---------
  73. .. _class_EditorSettings_constant_NOTIFICATION_EDITOR_SETTINGS_CHANGED:
  74. - **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.
  75. Method Descriptions
  76. -------------------
  77. .. _class_EditorSettings_method_add_property_info:
  78. - void **add_property_info** **(** :ref:`Dictionary<class_Dictionary>` info **)**
  79. Adds a custom property info to a property. The dictionary must contain:
  80. - ``name``: :ref:`String<class_String>` (the name of the property)
  81. - ``type``: :ref:`int<class_int>` (see :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>`)
  82. - optionally ``hint``: :ref:`int<class_int>` (see :ref:`PropertyHint<enum_@GlobalScope_PropertyHint>`) and ``hint_string``: :ref:`String<class_String>`
  83. **Example:**
  84. .. tabs::
  85. .. code-tab:: gdscript
  86. var settings = EditorInterface.get_editor_settings()
  87. settings.set("category/property_name", 0)
  88. var property_info = {
  89. "name": "category/property_name",
  90. "type": TYPE_INT,
  91. "hint": PROPERTY_HINT_ENUM,
  92. "hint_string": "one,two,three"
  93. }
  94. settings.add_property_info(property_info)
  95. .. code-tab:: csharp
  96. var settings = GetEditorInterface().GetEditorSettings();
  97. settings.Set("category/property_name", 0);
  98. var propertyInfo = new Godot.Collections.Dictionary
  99. {
  100. {"name", "category/propertyName"},
  101. {"type", Variant.Type.Int},
  102. {"hint", PropertyHint.Enum},
  103. {"hint_string", "one,two,three"}
  104. };
  105. settings.AddPropertyInfo(propertyInfo);
  106. ----
  107. .. _class_EditorSettings_method_erase:
  108. - void **erase** **(** :ref:`String<class_String>` property **)**
  109. Erases the setting whose name is specified by ``property``.
  110. ----
  111. .. _class_EditorSettings_method_get_favorites:
  112. - :ref:`PackedStringArray<class_PackedStringArray>` **get_favorites** **(** **)** |const|
  113. Returns the list of favorite files and directories for this project.
  114. ----
  115. .. _class_EditorSettings_method_get_project_metadata:
  116. - :ref:`Variant<class_Variant>` **get_project_metadata** **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` default=null **)** |const|
  117. 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>`.
  118. ----
  119. .. _class_EditorSettings_method_get_project_settings_dir:
  120. - :ref:`String<class_String>` **get_project_settings_dir** **(** **)** |const|
  121. Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved.
  122. ----
  123. .. _class_EditorSettings_method_get_recent_dirs:
  124. - :ref:`PackedStringArray<class_PackedStringArray>` **get_recent_dirs** **(** **)** |const|
  125. Returns the list of recently visited folders in the file dialog for this project.
  126. ----
  127. .. _class_EditorSettings_method_get_setting:
  128. - :ref:`Variant<class_Variant>` **get_setting** **(** :ref:`String<class_String>` name **)** |const|
  129. 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.
  130. ----
  131. .. _class_EditorSettings_method_has_setting:
  132. - :ref:`bool<class_bool>` **has_setting** **(** :ref:`String<class_String>` name **)** |const|
  133. Returns ``true`` if the setting specified by ``name`` exists, ``false`` otherwise.
  134. ----
  135. .. _class_EditorSettings_method_property_can_revert:
  136. - :ref:`bool<class_bool>` **property_can_revert** **(** :ref:`String<class_String>` name **)**
  137. 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.
  138. ----
  139. .. _class_EditorSettings_method_property_get_revert:
  140. - :ref:`Variant<class_Variant>` **property_get_revert** **(** :ref:`String<class_String>` name **)**
  141. 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.
  142. ----
  143. .. _class_EditorSettings_method_set_builtin_action_override:
  144. - void **set_builtin_action_override** **(** :ref:`String<class_String>` name, :ref:`Array<class_Array>` actions_list **)**
  145. ----
  146. .. _class_EditorSettings_method_set_favorites:
  147. - void **set_favorites** **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)**
  148. Sets the list of favorite files and directories for this project.
  149. ----
  150. .. _class_EditorSettings_method_set_initial_value:
  151. - void **set_initial_value** **(** :ref:`StringName<class_StringName>` name, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` update_current **)**
  152. 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.
  153. ----
  154. .. _class_EditorSettings_method_set_project_metadata:
  155. - void **set_project_metadata** **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` data **)**
  156. 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>`.
  157. ----
  158. .. _class_EditorSettings_method_set_recent_dirs:
  159. - void **set_recent_dirs** **(** :ref:`PackedStringArray<class_PackedStringArray>` dirs **)**
  160. Sets the list of recently visited folders in the file dialog for this project.
  161. ----
  162. .. _class_EditorSettings_method_set_setting:
  163. - void **set_setting** **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value **)**
  164. 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.
  165. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  166. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  167. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  168. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  169. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  170. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`