Set the Value of a Setting#
You can interact with app, extension, and user settings using the ISettings
interface from the carb.settings
module. This snippet shows how to set the value of a new or existing setting.
Note
Each extension puts settings in /ext/[ext_name]/
to not conflict with settings from other extensions. Extensions should also list their settings in their extension.toml
to make the settings discoverable to users and developers.
import carb.settings
settings = carb.settings.get_settings()
# set different types into different keys
settings.set("/exts/your.ext.name/test/value_int", 23)
settings.set("/exts/your.ext.name/test/value_float", 502.45)
settings.set("/exts/your.ext.name/test/value_bool", False)
settings.set("/exts/your.ext.name/test/value_str", "summer")
settings.set("/exts/your.ext.name/test/value_array", [9,13,17,21])
settings.set("/exts/your.ext.name/test/value_dict", { "a": 2, "b": "winter"})
# print all:
print(settings.get("/exts/your.ext.name/test"))