Skip to content

Game.Settings.OnSettingsAppliedHandler

Assembly: Assembly-CSharp.dll
Namespace: Game.Settings

Type: delegate

Base: System.MulticastDelegate

Summary:
Represents the signature for callbacks invoked when a game setting is applied. Handlers receive a single parameter of type Game.Settings.Setting that identifies which setting was applied (and typically contains the new value and metadata). This delegate is used by events or callbacks raised by the settings system so mods can react when settings change.


Fields

  • This delegate type declares no instance fields.
    {{ The delegate itself is a compiler-generated type derived from System.MulticastDelegate; any backing fields are runtime/internal. }}

Properties

  • This delegate type exposes no custom properties.
    {{ Use the methods (Invoke/BeginInvoke/EndInvoke) to interact with the delegate; there are no additional properties to query. }}

Constructors

  • public OnSettingsAppliedHandler(object object, IntPtr method)
    {{ Standard delegate constructor generated by the compiler. You normally do not construct delegates with this signature directly — use method group conversion or the delegate keyword. Example: new OnSettingsAppliedHandler(MyHandler) or simply MyHandler when subscribing to an event. }}

Methods

  • public void Invoke(Setting setting)
    {{ The primary invocation method. When the associated event is raised, this method is called and each subscribed handler receives the Setting instance describing the applied setting. Handlers should be quick and avoid long/blocking work because these callbacks are generally invoked on the main game thread. }}

  • public System.IAsyncResult BeginInvoke(Setting setting, System.AsyncCallback callback, object @object)
    {{ Optional asynchronous begin method provided by delegates. Rarely used in Unity/CSL modding; prefer main-thread-safe operations. }}

  • public void EndInvoke(System.IAsyncResult result)
    {{ Completes an asynchronous invocation started by BeginInvoke. }}

Usage Example

// Example handler method
void OnSettingApplied(Game.Settings.Setting setting)
{
    // Inspect the setting (key, new value, etc.) and react accordingly
    Debug.Log($"Setting applied: {setting.Name} = {setting.Value}");
    // Keep work light — this is usually called on the main game thread
}

// Subscribing to an event that uses the delegate (example event name)
// Replace SettingsManager.Instance.SettingsApplied with the actual event in the game's API.
SettingsManager.Instance.SettingsApplied += OnSettingApplied;

// Later, unsubscribe to avoid leaks (for example on mod unload)
SettingsManager.Instance.SettingsApplied -= OnSettingApplied;

{{ NOTES: - The exact event or manager that exposes this delegate may vary; check Game.Settings.* types (e.g., SettingsManager) for the concrete event. - The Setting parameter type is in Game.Settings; consult Game.Settings.Setting for fields/properties (name/key, value, type, etc.). - Be careful to unsubscribe handlers when your mod is disabled/unloaded to avoid referencing destroyed objects. - Avoid long-running or blocking work in the handler — offload heavy tasks to background threads carefully, and marshal results back to the main thread before interacting with Unity APIs. }}