Info
IAction - one async step you can run from a list, e.g. on an Action Wheel wedge or a debug menu button. Code in Polis.Core.Utils.Actions
Usage
UniTask Execute()
- Implementations
CompositeAction - a list of actions, Sequential (each awaited in turn) or Parallel (all at once, waits for all)
ScriptableVariableAssignAction (set an AScriptableVariable<T> to a value), SetAllowMicAction, SetCurrentSceneSetupAction, ReturnHomeAction
StartNetworkAction, TakeOwnershipAction, OpenTabletAction / CloseTabletAction, AppQuitAction, AppRestartAction
SetRuntimeContextAction (sets a RuntimeContext key, empty removes it), TrackAnalyticsEventAction (an analytics event)
DelegateAction - wraps a lambda, for code only (not in the dropdown)
IContextAction<TContext> - an action that also takes a context, e.g. ActionWheelContext (hand and anchor). action.Execute(context) passes it when the action accepts it, otherwise calls plain Execute()
- Used by the Action Wheel wedges (
SingleActionWheelWedge, ToggleActionWheelWedge), debug menu buttons, dialog results (ActionDialogResult) and commands (CommandRegistry)
Example
[Serializable]
public class LogAction : IAction
{
[SerializeField]
private string _Message;
public UniTask Execute()
{
Debug.Log(_Message);
return UniTask.CompletedTask;
}
}
Extending
- Implement
IAction as a [Serializable] class, it shows up in the type dropdown
Gotchas
- Action Wheel wedges call
Execute() without awaiting, all actions in the list start at once. Wrap them in a Sequential CompositeAction when order matters