Skip to content

Game.Input.UIInputCombinedAction

Assembly: Assembly-CSharp
Namespace: Game.Input

Type: class (ScriptableObject)

Base: UIBaseInputAction

Summary:
A composite UI input action that groups multiple UIInputActionPart entries into a single logical action. When a state for this combined action is requested, the class creates a UIInputAction.State for each part and wraps them in a nested UIInputCombinedAction.State proxy. The combined state forwards queries (pressed, released, in-progress, magnitude, value reads) to its underlying part states and resolves values based on the largest magnitude. This is useful to represent a single logical UI command that can be triggered from multiple sources (parts) and present a single proxy to UI code or input consumers.


Fields

  • public UIInputActionPart[] m_Parts
    Stores the individual parts that make up this combined action. Each part knows how to create its own ProxyAction and contains masks/transform/display data used when creating per-source states. This field is serialized on the ScriptableObject and defines which input bindings compose the combined action.

  • private readonly UIInputAction.State[] m_States (nested: UIInputCombinedAction.State)
    Holds the per-part UIInputAction.State instances inside the nested State proxy. The combined-state methods iterate this array to answer queries (pressed, released, magnitude, etc.) by checking all contained states.

Properties

  • public override IReadOnlyList<UIInputActionPart> actionParts { get; }
    Returns the configured m_Parts array. Provides the base-class contract to enumerate parts that form the action.

  • public IReadOnlyList<ProxyAction> actions { get; } (nested: UIInputCombinedAction.State)
    Returns a read-only list of the ProxyAction objects from each underlying UIInputAction.State. The implementation selects each state's .action and materializes them into an array.

  • public bool enabled { get; set; } (nested: UIInputCombinedAction.State)
    When read, returns true if any underlying state is enabled. When written, sets the enabled flag on every contained UIInputAction.State, enabling or disabling the whole combined action.

  • bool IProxyAction.enabled (nested: explicit interface implementation)
    Explicit interface mapping that forwards to the above enabled property so consumers using the IProxyAction interface can enable/disable the combined action.

Constructors

  • public UIInputCombinedAction()
    Default ScriptableObject constructor (asset is normally created via the CreateAssetMenu attribute present on the class). No special runtime initialization is required on construction.

  • public State(params UIInputAction.State[] states) (nested: UIInputCombinedAction.State)
    Creates a combined/state proxy wrapping the provided array of UIInputAction.State instances. The parameter list allows constructing the combined state from an arbitrary number of part states.

Methods

  • public override IProxyAction GetState(string source)
    Creates a UIInputAction.State for each UIInputActionPart in m_Parts using the part's GetProxyAction() and GetDisplayName(part, source) (inherited helper). Wraps those states into a new UIInputCombinedAction.State and returns it as IProxyAction. This is the typical runtime entry point to obtain a per-source proxy representing the combined input.

  • public override IProxyAction GetState(string source, DisplayGetter displayNameGetter)
    Variant that uses a caller-supplied displayNameGetter to compute display overrides for each part. If the combined action contains exactly one part, it returns a single UIInputAction.State directly (not wrapped) for efficiency; otherwise it creates and returns a combined State as above.

Nested State methods (forwarding semantics):

  • public bool WasPressedThisFrame()
    Returns true if any underlying part state reports WasPressedThisFrame().

  • public bool WasReleasedThisFrame()
    Returns true if any underlying part state reports WasReleasedThisFrame().

  • public bool IsPressed()
    Returns true if any underlying part state reports IsPressed().

  • public bool IsInProgress()
    Returns true if any underlying part state reports IsInProgress().

  • public float GetMagnitude()
    Returns the maximum magnitude across all contained states (the combined-state picks the strongest input).

  • public T ReadValue<T>() where T : struct
    Chooses the state with the highest magnitude and returns that state's ReadValue(). If there are no states returns default(T). Useful for reading vector/float/button values from the active part.

  • public void Dispose()
    Disposes each contained UIInputAction.State (for cleanup / unsubscribing from events).

  • public event Action<ProxyAction, InputActionPhase> onInteraction (nested: add/remove)
    Adds/removes the given handler to/from every contained state's onInteraction event. The combined event forwards interactions from any part to subscribers as if they were a single action.

Usage Example

// The ScriptableObject asset is created via:
// [CreateAssetMenu(menuName = "Colossal/UI/UIInputCombinedAction")]
// and configured in the editor by adding UIInputActionPart entries.

public class MyUIHandler : MonoBehaviour
{
    public UIInputCombinedAction combinedActionAsset; // assign in inspector

    private IProxyAction _state; // returned proxy for a source (eg "keyboard", "gamepad")

    void Start()
    {
        // Request a state for a particular input source (source string is used by parts to pick display names / masks)
        _state = combinedActionAsset.GetState("keyboard");

        // If you need the concrete combined State to call ReadValue<T>() or WasPressedThisFrame()
        var combinedState = _state as UIInputCombinedAction.State;
        if (combinedState != null)
        {
            // Example: read a Vector2 from the currently dominant part
            Vector2 value = combinedState.ReadValue<Vector2>();

            // Example: check press/release
            if (combinedState.WasPressedThisFrame())
            {
                // handle press
            }
        }
    }
}

Notes: - The combined action returns the strongest/most relevant value by magnitude when multiple parts are active. - The class is intended for UI input handling where multiple bindings (parts) should map to the same logical UI command.