Contains global variables accessible from everywhere.
    public static class ProjectSettings

Contains global variables accessible from everywhere. Use GetSetting(string), SetSetting(string, object) or HasSetting(string) to access them. Variables stored in project.godot are also loaded into ProjectSettings, making this object very useful for reading custom game configuration options.

When naming a Project Settings property, use the full path to the setting including the category. For example, "application/config/name" for the project name. Category and property names can be viewed in the Project Settings dialog.

Inheritance Chain

Static Properties

    public static Object Singleton { get; }

Static Methods

    public static void AddPropertyInfo(Dictionary hint)

Adds a custom property info to a property. The dictionary must contain: name:String(the property’s name) and type:[int](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int](see TYPE_* in [@GlobalScope]), and optionally hint:[int](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int](see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String.

Example:

[codeblock]

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)

[/codeblock]

    public static void Clear(string name)

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

    public static int GetOrder(string name)

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

    public static object GetSetting(string name)

Returns the value of a setting.

Example:

[codeblock]

print(ProjectSettings.get_setting(“application/config/name”))

[/codeblock]

    public static string GlobalizePath(string path)

Converts a localized path (res://) to a full native OS path.

    public static bool HasSetting(string name)

Returns true if a configuration value is present.

    public static bool LoadResourcePack(string pack, bool replaceFiles = true)

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 replaceFiles is set to false.

    public static string LocalizePath(string path)

Convert a path to a localized path (res:// path).

    public static bool PropertyCanRevert(string name)

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

    public static object PropertyGetRevert(string name)

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

    public static Error Save()

Saves the configuration to the project.godot file.

    public static Error SaveCustom(string file)

Saves the configuration to a custom file.

    public static void SetInitialValue(string name, object value)

    public static void SetOrder(string name, int position)

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

    public static void SetSetting(string name, object value)
Tags: