project_settings.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. .. _doc_project_settings:
  2. Project Settings
  3. ================
  4. There are dozens of settings you can change to control a project's execution,
  5. including physics, rendering, and windowing settings. These settings can be
  6. changed from the **Project Settings** window, from code, or by manually editing
  7. the ``project.godot`` file. You can see a full list of settings in the
  8. :ref:`ProjectSettings <class_ProjectSettings>` class.
  9. Internally, Godot stores the settings for a project in a ``project.godot`` file,
  10. a plain text file in INI format. While this is human-readable and version control
  11. friendly, it's not the most convenient to edit. For that reason, the
  12. **Project Settings** window is available to edit these settings. To open the
  13. Project Settings, select **Project > Project Settings** from the main menu.
  14. .. figure:: img/project_settings_basic.webp
  15. :align: center
  16. The Project Settings window
  17. The **Project Settings** window is mainly used to change settings in the
  18. **General** tab. Additionally, there are tabs for the
  19. :ref:`Input Map <doc_input_examples_input_map>`,
  20. :ref:`Localization <doc_internationalizing_games>`,
  21. :ref:`Globals <doc_singletons_autoload>`,
  22. :ref:`Plugins <doc_installing_plugins_enabling_a_plugin>`, and
  23. **Import Defaults**. Usage of these other tabs is documented elsewhere.
  24. Changing project settings
  25. -------------------------
  26. The **General** tab of the project settings window works much like the inspector.
  27. It displays a list of project settings which you can change, just like inspector
  28. properties. There is a list of categories on the left, which you can use to select
  29. related groups of settings. You can also search for a specific setting with the
  30. **Filter Settings** field.
  31. Each setting has a default value. Settings can be reset to their default values
  32. by clicking the circular arrow **Reset** button next to each property.
  33. Changing project settings from code
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. You can use :ref:`set_setting() <class_ProjectSettings_method_set_setting>` to
  36. change a setting's value from code:
  37. .. tabs::
  38. .. code-tab:: gdscript GDScript
  39. ProjectSettings.set_setting("application/run/max_fps", 60)
  40. ProjectSettings.set_setting("display/window/size/mode", DisplayServer.WINDOW_MODE_WINDOWED)
  41. .. code-tab:: csharp
  42. ProjectSettings.SetSetting("application/run/max_fps", 60);
  43. ProjectSettings.SetSetting("display/window/size/mode", (int)DisplayServer.WindowMode.Windowed);
  44. However, many project settings are only read once when the game starts. After
  45. that, changing the setting with ``set_setting()`` will have no effect. Instead,
  46. most settings have a corresponding property or method on a runtime class like
  47. :ref:`Engine <class_Engine>` or :ref:`DisplayServer <class_DisplayServer>`:
  48. .. tabs::
  49. .. code-tab:: gdscript GDScript
  50. Engine.max_fps = 60
  51. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
  52. .. code-tab:: csharp
  53. Engine.MaxFps = 60;
  54. DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
  55. In general, project settings are duplicated at runtime in the
  56. :ref:`Engine <class_Engine>`, :ref:`PhysicsServer2D <class_PhysicsServer2D>`,
  57. :ref:`PhysicsServer3D <class_PhysicsServer3D>`,
  58. :ref:`RenderingServer <class_RenderingServer>`,
  59. :ref:`Viewport <class_Viewport>`, or :ref:`Window <class_Window>` classes. In the
  60. :ref:`ProjectSettings <class_ProjectSettings>` class reference, settings
  61. links to their equivalent runtime property or method.
  62. Reading project settings
  63. ------------------------
  64. You can read project settings with
  65. :ref:`get_setting() <class_ProjectSettings_method_get_setting>` or
  66. :ref:`get_setting_with_override() <class_ProjectSettings_method_get_setting_with_override>`:
  67. .. tabs::
  68. .. code-tab:: gdscript GDScript
  69. var max_fps = ProjectSettings.get_setting("application/run/max_fps")
  70. var window_mode = ProjectSettings.get_setting("display/window/size/mode")
  71. .. code-tab:: csharp
  72. int maxFps = (int)ProjectSettings.GetSetting("application/run/max_fps");
  73. var windowMode = (DisplayServer.WindowMode)(int)ProjectSettings.GetSetting("display/window/size/mode");
  74. Since many project settings are only read once at startup, the value in the
  75. project settings may no longer be accurate. In these cases, it's better to read
  76. the value from the runtime equivalent property or method:
  77. .. tabs::
  78. .. code-tab:: gdscript GDScript
  79. var max_fps = Engine.max_fps
  80. var window_mode = DisplayServer.window_get_mode()
  81. .. code-tab:: csharp
  82. int maxFps = Engine.MaxFps;
  83. DisplayServer.WindowMode windowMode = DisplayServer.WindowGetMode();
  84. Manually editing project.godot
  85. ------------------------------
  86. You can open the ``project.godot`` file using a text editor and manually
  87. change project settings. Note that if the ``project.godot`` file does not have a
  88. stored value for a particular setting, it is implicitly the default value of
  89. that setting. This means that if you are are manually editing the file, you may
  90. have to write in both the setting name *and* the value.
  91. In general, it is recommended to use the Project Settings window rather than
  92. manually edit ``project.godot``.
  93. Advanced project settings
  94. -------------------------
  95. .. figure:: img/project_settings_advanced.webp
  96. :align: center
  97. The advanced project settings
  98. By default, only some project settings are shown. To see all the project
  99. settings, enable the **Advanced Settings** toggle.