Skip to content

Game.UI.Widgets.IDisableCallback

Assembly: Assembly-CSharp (inferred)
Namespace: Game.UI.Widgets

Type: interface

Base: (none)

Summary:
Defines a simple interface for UI widgets that need a pluggable "disabled" check. Implementers expose a Func property named disabled which, when assigned, should return true when the widget must be considered disabled. This allows external code or higher-level systems to provide dynamic-disabled logic without subclassing the widget.


Fields

  • None.
    No fields are declared on this interface; only a single property is defined.

Properties

  • public System.Func<bool> disabled { get; set; }
    A callback that should return true when the widget is disabled. The property may be null — callers should handle null (for example treating null as "not disabled" or as a default state). Assign a lightweight, thread-affine delegate (UI thread) as appropriate for your widget.

Constructors

  • Interfaces do not declare constructors.
    No constructors are defined because this is an interface; concrete types implementing this interface will provide their own constructors.

Methods

  • None declared on the interface.
    Only the property accessors are implied by the property definition.

Usage Example

using System;
using Game.UI.Widgets;

public class MyWidget : IDisableCallback
{
    // Implement the interface property
    public Func<bool> disabled { get; set; }

    public MyWidget()
    {
        // Example: disable the widget at runtime based on some condition
        disabled = () => DateTime.Now.Hour < 9 || DateTime.Now.Hour > 17;
    }

    public void Render()
    {
        // Safely evaluate the disabled callback
        bool isDisabled = disabled?.Invoke() ?? false;

        if (isDisabled)
        {
            // Render disabled visuals / skip interaction
        }
        else
        {
            // Normal rendering / interaction
        }
    }
}

Notes and recommendations: - Treat the callback as UI-thread code; avoid long-running or blocking operations inside the Func<bool>. - Consider clear ownership of who sets/clears the disabled delegate to avoid lifecycle issues (e.g., dangling references). - If multiple conditions need to be combined, assign a delegate that composes them rather than chaining multiple assignments that overwrite each other.