Click or drag to resize

ProjectSettings Methods

The ProjectSettings type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAddPropertyInfo

Adds a custom property info to a property. The dictionary must contain:

- name: String (the property's name)

- type: Int32 (see VariantType)

- optionally hint: Int32 (see PropertyHint) and hint_string: String

Example:

ProjectSettings.set("category/property_name", 0)

var property_info = {
    "name": "category/property_name",
    "type": TYPE_INT,
    "hint": PROPERTY_HINT_ENUM,
    "hint_string": "one,two,three"
}

ProjectSettings.add_property_info(property_info)

Public methodStatic memberClear

Clears the whole configuration (not recommended, may break things).

Public methodStatic memberGetOrder

Returns the order of a configuration value (influences when saved to the config file).

Public methodStatic memberGetSetting

Returns the value of a setting.

Example:

print(ProjectSettings.get_setting("application/config/name"))

Public methodStatic memberGlobalizePath

Returns the absolute, native OS path corresponding to the localized path (starting with res:// or user://). The returned path will vary depending on the operating system and user preferences. See File paths in Godot projects to see what those paths convert to. See also LocalizePath(String).

Note: GlobalizePath(String) with res:// will not work in an exported project. Instead, prepend the executable's base directory to the path when running from an exported project:

var path = ""
if OS.has_feature("editor"):
    # Running from an editor binary.
    # `path` will contain the absolute path to `hello.txt` located in the project root.
    path = ProjectSettings.globalize_path("res://hello.txt")
else:
    # Running from an exported project.
    # `path` will contain the absolute path to `hello.txt` next to the executable.
    # This is *not* identical to using `ProjectSettings.globalize_path()` with a `res://` path,
    # but is close enough in spirit.
    path = OS.get_executable_path().get_base_dir().plus_file("hello.txt")

Public methodStatic memberHasSetting

Returns true if a configuration value is present.

Public methodStatic memberLoadResourcePack

Loads the contents of the .pck or .zip file specified by pack into the resource filesystem (res://). Returns true on success.

Note: If a file from pack shares the same path as a file already in the resource filesystem, any attempts to load that file will use the file from pack unless replace_files is set to false.

Note: The optional offset parameter can be used to specify the offset in bytes to the start of the resource pack. This is only supported for .pck files.

Public methodStatic memberLocalizePath

Returns the localized path (starting with res://) corresponding to the absolute, native OS path. See also GlobalizePath(String).

Public methodStatic memberPropertyCanRevert

Returns true if the specified property exists and its initial value differs from the current value.

Public methodStatic memberPropertyGetRevert

Returns the specified property's initial value. Returns null if the property does not exist.

Public methodStatic memberSave

Saves the configuration to the project.godot file.

Note: This method is intended to be used by editor plugins, as modified ProjectSettings can't be loaded back in the running app. If you want to change project settings in exported projects, use SaveCustom(String) to save override.cfg file.

Public methodStatic memberSaveCustom

Saves the configuration to a custom file. The file extension must be .godot (to save in text-based ConfigFile format) or .binary (to save in binary format). You can also save override.cfg file, which is also text, but can be used in exported projects unlike other formats.

Public methodStatic memberSetInitialValue

Sets the specified property's initial value. This is the value the property reverts to.

Public methodStatic memberSetOrder

Sets the order of a configuration value (influences when saved to the config file).

Public methodStatic memberSetSetting

Sets the value of a setting.

Example:

ProjectSettings.set_setting("application/config/name", "Example")

Top
See Also