Skip to content

Game.Input.UIInputOverrideAction

Assembly:
Assembly-CSharp

Namespace:
Game.Input

Type:
class

Base:
UIBaseInputAction

Summary:
A ScriptableObject input action that proxies to another UIBaseInputAction (m_Source) but can override how the action is presented to the UI. This asset forwards the action parts to the source action and wraps the source's proxy actions with a DisplayNameOverride depending on display masks and the m_OverridePriority flag. It is intended to be created in the Unity editor via the CreateAssetMenu entry "Colossal/UI/UIInputOverrideAction".


Fields

  • public UIBaseInputAction m_Source
    The underlying source UIBaseInputAction that this override forwards to. All actionParts are delegated to this source and GetState calls are proxied through it. This must be assigned (non-null) for the override to function; otherwise a NullReferenceException will occur at runtime.

  • public bool m_OverridePriority
    Controls whether this override uses its own display mask/priority (and alias) when creating DisplayNameOverride wrappers, or whether it defers to the source action's display mask/priority. If true, the override checks this object's m_DisplayMask and uses this object's m_DisplayPriority. If false, it checks the source's m_DisplayMask and uses the source's m_DisplayPriority (while still applying this object's m_AliasName).

Properties

  • public override IReadOnlyList<UIInputActionPart> actionParts => m_Source.actionParts
    Exposes the action parts from the source action. This class does not define its own parts; it simply returns whatever parts the referenced m_Source provides. Use this property to inspect the individual input parts that compose the proxied action.

Constructors

  • public UIInputOverrideAction()
    Default constructor (ScriptableObject). Instances are typically created in the Unity editor using the CreateAssetMenu ("Colossal/UI/UIInputOverrideAction") or at runtime via ScriptableObject.CreateInstance. No custom construction logic is defined in this class.

Methods

  • public override IProxyAction GetState(string source)
    Calls the source action's GetState and supplies a custom DisplayGetter delegate. The delegate will, depending on m_OverridePriority and the device mask passed by the source, return a DisplayNameOverride that wraps the source ProxyAction:

  • If m_OverridePriority is true:

    • If the mask intersects this object's m_DisplayMask, a DisplayNameOverride is created using this object's m_AliasName and this object's m_DisplayPriority.
    • Otherwise null is returned for that display path.
  • If m_OverridePriority is false:
    • If the mask intersects m_Source.m_DisplayMask, a DisplayNameOverride is created using this object's m_AliasName but the source action's m_DisplayPriority.
    • Otherwise null is returned.

Notes: - The alias (m_AliasName) used in the DisplayNameOverride is always taken from this UIInputOverrideAction instance. - The method relies on fields/properties inherited from UIBaseInputAction such as m_DisplayMask, m_DisplayPriority and m_AliasName. - Ensure m_Source is set to avoid runtime exceptions.

  • public override IProxyAction GetState(string source, DisplayGetter displayNameGetter)
    Directly forwards the call to the source action, passing along the provided DisplayGetter. Use this overload when you want to supply your own display-name resolver rather than using the override's internal delegate.

Usage Example

// Create and configure at runtime (editor creation is typical):
var overrideAction = ScriptableObject.CreateInstance<Game.Input.UIInputOverrideAction>();
overrideAction.m_Source = someExistingUIBaseInputAction; // must be set
overrideAction.m_OverridePriority = true;
overrideAction.m_AliasName = "CustomAlias"; // inherited from UIBaseInputAction
overrideAction.m_DisplayPriority = DisplayPriority.High; // enum inherited from base

// Retrieve the proxy action for a player/source id
IProxyAction proxy = overrideAction.GetState("Player1");
// proxy will be a wrapped DisplayNameOverride depending on masks/priorities

{{ Notes: - This asset is useful when you want to change only the presentation (display name and priority/mask behavior) of an existing UI input action without duplicating its parts or logic. - Because this object relies on m_Source, it is safe and intended to be used as an editor asset that references another action asset. - When modding Cities: Skylines 2, add this asset via the Unity editor menu (Colossal -> UI -> UIInputOverrideAction) and assign the source action and desired display settings. }}