Game.UI.Widgets.IInvokable
Assembly:
Namespace: Game.UI.Widgets
Type: interface
Base: IWidget, IJsonWritable
Summary:
IInvokable is a small interface for UI widgets that can be "invoked" or activated programmatically (for example buttons, menu items, or other interactive controls). Implementors must provide an Invoke method that performs the widget's action. The interface also inherits IWidget (widget lifecycle / presentation) and IJsonWritable (ability to serialize state), so implementations are expected to integrate with the UI system and support JSON serialization where required.
Fields
- (none)
No fields are declared on the interface itself. Implementations may have internal state fields as needed. {{ Implementing classes are responsible for their own storage and any thread-safety considerations. }}
Properties
- (none declared on this interface)
The interface does not declare properties directly. Implementations will typically expose widget-specific properties via IWidget or their own members. {{ Check IWidget for lifecycle and visual properties that your implementation will likely need to support. }}
Constructors
- (interfaces do not define constructors)
Implementing classes should provide appropriate constructors or initialization via lifecycle methods (e.g., OnCreate / Awake) from the widget base classes they use. {{ If your widget derives from a UI base class, use that class's initialization pattern to hook up any resources. }}
Methods
void Invoke()
Performs the widget's action. This method is intended to be called when the widget is activated programmatically or by user interaction. Implementations should execute the intended behavior (open panels, toggle state, trigger events, etc.). Document any side effects (UI updates, game state changes) and ensure calls happen on the main thread if interacting with Unity/Game state. {{ Keep implementations concise, avoid heavy blocking work, and consider raising events or scheduling jobs for longer tasks. Also ensure JSON serialization (IJsonWritable) preserves any state necessary for consistent restore. }}
Usage Example
// Minimal example showing how a widget might implement IInvokable.
// Note: IWidget and IJsonWritable members are omitted for brevity.
public class MyActionWidget : IInvokable
{
public void Invoke()
{
// Perform the widget's action:
// e.g. open a panel, trigger a game action, or toggle a state.
UnityEngine.Debug.Log("MyActionWidget invoked");
// TODO: interact with your UI or game systems here.
}
// Implement IWidget and IJsonWritable members as required by your base types.
// For example, initialization and JSON serialization methods should be provided.
}
{{ YOUR_INFO }}