class_editorsettings.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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:`Reference<class_Reference>` **<** :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. ::
  16. # `settings.set("some/property", value)` also works as this class overrides `_set()` internally.
  17. settings.set_setting("some/property",value)
  18. # `settings.get("some/property", value)` also works as this class overrides `_get()` internally.
  19. settings.get_setting("some/property")
  20. var list_of_settings = settings.get_property_list()
  21. **Note:** This class shouldn't be instantiated directly. Instead, access the singleton using :ref:`EditorInterface.get_editor_settings<class_EditorInterface_method_get_editor_settings>`.
  22. Methods
  23. -------
  24. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`add_property_info<class_EditorSettings_method_add_property_info>` **(** :ref:`Dictionary<class_Dictionary>` info **)** |
  26. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`erase<class_EditorSettings_method_erase>` **(** :ref:`String<class_String>` property **)** |
  28. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_favorites<class_EditorSettings_method_get_favorites>` **(** **)** |const| |
  30. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :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| |
  32. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_String>` | :ref:`get_project_settings_dir<class_EditorSettings_method_get_project_settings_dir>` **(** **)** |const| |
  34. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_recent_dirs<class_EditorSettings_method_get_recent_dirs>` **(** **)** |const| |
  36. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Variant<class_Variant>` | :ref:`get_setting<class_EditorSettings_method_get_setting>` **(** :ref:`String<class_String>` name **)** |const| |
  38. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`String<class_String>` | :ref:`get_settings_dir<class_EditorSettings_method_get_settings_dir>` **(** **)** |const| |
  40. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`has_setting<class_EditorSettings_method_has_setting>` **(** :ref:`String<class_String>` name **)** |const| |
  42. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`property_can_revert<class_EditorSettings_method_property_can_revert>` **(** :ref:`String<class_String>` name **)** |
  44. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Variant<class_Variant>` | :ref:`property_get_revert<class_EditorSettings_method_property_get_revert>` **(** :ref:`String<class_String>` name **)** |
  46. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_favorites<class_EditorSettings_method_set_favorites>` **(** :ref:`PoolStringArray<class_PoolStringArray>` dirs **)** |
  48. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_initial_value<class_EditorSettings_method_set_initial_value>` **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` update_current **)** |
  50. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | 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 **)** |
  52. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_recent_dirs<class_EditorSettings_method_set_recent_dirs>` **(** :ref:`PoolStringArray<class_PoolStringArray>` dirs **)** |
  54. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_setting<class_EditorSettings_method_set_setting>` **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value **)** |
  56. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. Signals
  58. -------
  59. .. _class_EditorSettings_signal_settings_changed:
  60. - **settings_changed** **(** **)**
  61. Emitted after any editor setting has changed.
  62. Constants
  63. ---------
  64. .. _class_EditorSettings_constant_NOTIFICATION_EDITOR_SETTINGS_CHANGED:
  65. - **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.
  66. Method Descriptions
  67. -------------------
  68. .. _class_EditorSettings_method_add_property_info:
  69. - void **add_property_info** **(** :ref:`Dictionary<class_Dictionary>` info **)**
  70. Adds a custom property info to a property. The dictionary must contain:
  71. - ``name``: :ref:`String<class_String>` (the name of the property)
  72. - ``type``: :ref:`int<class_int>` (see :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>`)
  73. - optionally ``hint``: :ref:`int<class_int>` (see :ref:`PropertyHint<enum_@GlobalScope_PropertyHint>`) and ``hint_string``: :ref:`String<class_String>`
  74. **Example:**
  75. ::
  76. editor_settings.set("category/property_name", 0)
  77. var property_info = {
  78. "name": "category/property_name",
  79. "type": TYPE_INT,
  80. "hint": PROPERTY_HINT_ENUM,
  81. "hint_string": "one,two,three"
  82. }
  83. editor_settings.add_property_info(property_info)
  84. ----
  85. .. _class_EditorSettings_method_erase:
  86. - void **erase** **(** :ref:`String<class_String>` property **)**
  87. Erases the setting whose name is specified by ``property``.
  88. ----
  89. .. _class_EditorSettings_method_get_favorites:
  90. - :ref:`PoolStringArray<class_PoolStringArray>` **get_favorites** **(** **)** |const|
  91. Returns the list of favorite files and directories for this project.
  92. ----
  93. .. _class_EditorSettings_method_get_project_metadata:
  94. - :ref:`Variant<class_Variant>` **get_project_metadata** **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` default=null **)** |const|
  95. 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>`.
  96. ----
  97. .. _class_EditorSettings_method_get_project_settings_dir:
  98. - :ref:`String<class_String>` **get_project_settings_dir** **(** **)** |const|
  99. Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved.
  100. ----
  101. .. _class_EditorSettings_method_get_recent_dirs:
  102. - :ref:`PoolStringArray<class_PoolStringArray>` **get_recent_dirs** **(** **)** |const|
  103. Returns the list of recently visited folders in the file dialog for this project.
  104. ----
  105. .. _class_EditorSettings_method_get_setting:
  106. - :ref:`Variant<class_Variant>` **get_setting** **(** :ref:`String<class_String>` name **)** |const|
  107. 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.
  108. ----
  109. .. _class_EditorSettings_method_get_settings_dir:
  110. - :ref:`String<class_String>` **get_settings_dir** **(** **)** |const|
  111. Gets the global settings path for the engine. Inside this path, you can find some standard paths such as:
  112. ``settings/tmp`` - Used for temporary storage of files
  113. ``settings/templates`` - Where export templates are located
  114. ----
  115. .. _class_EditorSettings_method_has_setting:
  116. - :ref:`bool<class_bool>` **has_setting** **(** :ref:`String<class_String>` name **)** |const|
  117. Returns ``true`` if the setting specified by ``name`` exists, ``false`` otherwise.
  118. ----
  119. .. _class_EditorSettings_method_property_can_revert:
  120. - :ref:`bool<class_bool>` **property_can_revert** **(** :ref:`String<class_String>` name **)**
  121. 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.
  122. ----
  123. .. _class_EditorSettings_method_property_get_revert:
  124. - :ref:`Variant<class_Variant>` **property_get_revert** **(** :ref:`String<class_String>` name **)**
  125. 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.
  126. ----
  127. .. _class_EditorSettings_method_set_favorites:
  128. - void **set_favorites** **(** :ref:`PoolStringArray<class_PoolStringArray>` dirs **)**
  129. Sets the list of favorite files and directories for this project.
  130. ----
  131. .. _class_EditorSettings_method_set_initial_value:
  132. - void **set_initial_value** **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` update_current **)**
  133. 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.
  134. ----
  135. .. _class_EditorSettings_method_set_project_metadata:
  136. - void **set_project_metadata** **(** :ref:`String<class_String>` section, :ref:`String<class_String>` key, :ref:`Variant<class_Variant>` data **)**
  137. 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>`.
  138. ----
  139. .. _class_EditorSettings_method_set_recent_dirs:
  140. - void **set_recent_dirs** **(** :ref:`PoolStringArray<class_PoolStringArray>` dirs **)**
  141. Sets the list of recently visited folders in the file dialog for this project.
  142. ----
  143. .. _class_EditorSettings_method_set_setting:
  144. - void **set_setting** **(** :ref:`String<class_String>` name, :ref:`Variant<class_Variant>` value **)**
  145. 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.
  146. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  147. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  148. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`