Game.Input.UIInputActionPart
Assembly:
Assembly-CSharp (typical Unity/CS mod assembly; adjust if your mod uses a different assembly)
Namespace: Game.Input
Type: class
Base: System.Object
Summary: A small serializable container used by UI input code to reference an Input System action together with how the UI should process it. Exposed fields allow the action reference, processing semantics (ProcessAs), coordinate transform behavior (Transform), and a device-type mask that limits which input devices the action applies to. Intended to be editable in the Unity inspector and used at runtime to obtain the game's ProxyAction for the referenced InputAction.
Fields
-
public InputActionReference m_Action
A reference to a Unity Input System InputAction (InputActionReference). Set this in the inspector to point to the desired action. Note: the runtime code uses m_Action.action when resolving the ProxyAction, so m_Action and its .action should not be null. -
public UIBaseInputAction.ProcessAs m_ProcessAs
Defines how the UI should process this action (processing mode). This is an enum defined on UIBaseInputAction that controls behavior such as whether the action is treated as a button, axis, toggle, etc. Used by UI input handling code to interpret the action's values. -
public UIBaseInputAction.Transform m_Transform
Specifies any transform/interpretation to apply to the action value before the UI handles it (for example axis inversion, scaling, or coordinate-space transform). This uses the Transform enum/type defined on UIBaseInputAction. -
public InputManager.DeviceType m_Mask = InputManager.DeviceType.All
A device-type mask (flags) indicating which input device types this mapping applies to (for example Keyboard, Gamepad, Touch, etc.). Defaults to All. This is used to filter actions by device type at runtime.
Properties
- None
This class exposes only public fields and helper methods; it defines no C# properties.
Constructors
public UIInputActionPart()
The default parameterless constructor (compiler-provided). Instances are typically created and serialized by Unity when used as a serializable field on a MonoBehaviour or ScriptableObject. No custom initialization logic is present in this class.
Methods
-
public ProxyAction GetProxyAction()
: ProxyAction
Looks up and returns the ProxyAction corresponding to the referenced InputAction. Internally calls InputManager.instance.FindAction(m_Action.action). Can throw or return null if InputManager.instance is null or if m_Action/action is null — caller code should ensure these are valid or handle exceptions. -
public bool TryGetProxyAction(out ProxyAction action)
: bool
Attempts to resolve the ProxyAction for the referenced InputAction, returning true on success and setting the out parameter. Internally calls InputManager.instance.TryFindAction(m_Action.action, out action). Safer to use than GetProxyAction when the action or InputManager might be missing.
Usage Example
// Example: resolving the proxy action for a UI-mapped action
UIInputActionPart actionPart = new UIInputActionPart {
m_Action = myInputActionReference,
m_ProcessAs = UIBaseInputAction.ProcessAs.Button,
m_Transform = UIBaseInputAction.Transform.None,
m_Mask = InputManager.DeviceType.All
};
if (actionPart.TryGetProxyAction(out var proxy))
{
// Use the proxy action with UI input handling
// e.g., read proxy.currentValue or subscribe to events depending on ProxyAction API
}
else
{
Debug.LogWarning("Failed to find ProxyAction for " + actionPart.m_Action);
}
Additional notes and tips: - Because this class is marked [Serializable] and uses public fields, it is intended to be configured through the Unity inspector. - Always validate that InputManager.instance is available before calling GetProxyAction, and prefer TryGetProxyAction when code must be robust against missing actions or late-initialized systems. - When assigning m_Action in the inspector, ensure the referenced InputAction exists and is enabled in the Input System; otherwise action lookups will fail. - Use m_Mask to limit the mapping to specific device types to avoid processing the same logical action from unintended hardware.