Subscribe to Setting Changes

The extension contains the SettingChangeSubscription class that allows you to subscribe a callback for when a setting value changes. This is useful for when you want to allow other parts of the app to interactively change the behavior of your extension. This snippet shows how to subscribe to settings value changes and provide a callback function to execute code whenever a setting changes.


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()

def on_change(value, change_type: carb.settings.ChangeEventType):
    print(value, change_type)

# subscribe to value changes, returned object is subscription holder. To unsubscribe - destroy it.
subscription1 ="/exts/", on_change)

settings.set("/exts/", 23)
settings.set("/exts/", "fall")
settings.set("/exts/", None)
settings.set("/exts/", 89)

# release the subscription reference to stop receiving callbacks.
subscription1 = None
# no more notifications
settings.set("/exts/", 100)