Gears
API ReferenceAttributes

SettingOnValueChangedAttribute

Binds a static method to OnValueChanged. Raised on global value settings; on a world path the method is bound invoke-only.

Sealed classNamespace GearsAPI.AttributesAssembly GearsAPI.dllSource
public sealed class SettingOnValueChangedAttribute : SettingListenerAttribute

Binds a static method to the named setting's OnValueChanged event (IGlobalValueSetting<T>), which fires when the applied value changes. Required method signature: static void M(IValueModSetting<T> setting, T newValue). Pass includeInSync: true to have SyncSettingsToClass call the method with the setting's current SettingValue. A world setting raises no OnValueChanged - its applied value arrives with the world rather than changing under the player - so on a world path the method is bound invoke-only: never raised, and run only by SyncSettingsToClass. That makes includeInSync: true mandatory there, or the method can never run at all.

Inheritance: Object → Attribute → SettingPathAttribute → SettingListenerAttribute → SettingOnValueChangedAttribute

Constructors

SettingOnValueChangedAttribute(String, Boolean)

public SettingOnValueChangedAttribute(string settingPath, bool includeInSync = false)

Initializes the attribute with the setting path, and optionally opts the listener in to SyncSettingsToClass.

Properties

IncludeInSync

public bool IncludeInSync { get; }

Gets whether SyncSettingsToClass calls this listener with the setting's current SettingValue. Defaults to false, which leaves the listener running only when its event fires.

On this page