Game.Input.UIInputActionCollection
Assembly: Assembly-CSharp
Namespace: Game.Input
Type: class
Base: UnityEngine.ScriptableObject
Summary:
UIInputActionCollection is a ScriptableObject that holds a collection of UIBaseInputAction assets. It provides a helper method to look up an input action by alias name and return its current state (as an IProxyAction). The asset is creatable from the Unity menu via the CreateAssetMenu attribute ("Colossal/UI/UIInputActionCollection").
Fields
public UIBaseInputAction[] m_InputActions
Holds the array of UIBaseInputAction entries that the collection manages. This field is public and can be populated/edited in the Unity Inspector for the ScriptableObject asset.
Properties
- This class does not expose any C# properties.
Constructors
public UIInputActionCollection()
ScriptableObject-derived classes use Unity's creation pipeline; there is no custom constructor provided. Create instances via Unity's "Create" asset menu (Create -> Colossal -> UI -> UIInputActionCollection) or ScriptableObject.CreateInstance().
Methods
public IProxyAction GetActionState(string actionName, string source)
Looks up the first UIBaseInputAction in m_InputActions whose aliasName exactly equals actionName (string equality, case-sensitive). If none is found, the method returns null. If found, it calls that UIBaseInputAction's GetState method using a composed state name in the format: "{actionName} ({source})" and returns the resulting IProxyAction.
Behavior notes: - Uses LINQ FirstOrDefault to find the match. - Returns null if no matching action alias is present. - The returned IProxyAction comes from UIBaseInputAction.GetState — callers should check for null before using the result.
Usage Example
// Suppose you have a reference to the UIInputActionCollection asset (assigned in inspector or loaded at runtime).
public UIInputActionCollection inputCollection;
// Example usage to get the action state:
void UseActionState()
{
// Look up an action with alias "Select" coming from "Mouse"
IProxyAction actionState = inputCollection.GetActionState("Select", "Mouse");
if (actionState == null)
{
Debug.Log("Action not found: Select");
return;
}
// Use actionState (example: check if currently pressed or read value — depends on IProxyAction API)
// e.g., if (actionState.IsPressed) { ... }
}
Additional tips: - Because alias matching is exact and case-sensitive, ensure the aliasName on UIBaseInputAction entries matches the actionName used at lookup. - Use the CreateAssetMenu entry (Colossal -> UI -> UIInputActionCollection) to create and populate this asset in the editor.