If I set the binding path to <Touchscreen>/touch*/press like the docs say, how do I access the touches array in code? For context, I've generated the class for the input asset (ARInputActions). In the Action Editor I have (to simplify) 1 action called ScreenTouches which is set to Action Type = Pass Through and Control Type = Any. Here's the skimmed class that should access touches via Input Actions. See the Debug.Log that reads with an Hamletic tone and translates to: how do I extract all touches from the context? But I guess the question could be generalized to how do I access wildcarded Actions? Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Assertions; using UnityEngine.XR.ARFoundation; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; public class ARInteractor : MonoBehaviour { ARInputActions arInputActions; void OnEnable() { arInputActions.Enable(); } void OnDisable() { arInputActions.Disable(); } void Awake() { arInputActions = new ARInputActions(); } void Start() { arInputActions.TouchActions.TouchPress.performed += context => { Debug.Log("WHAT TO DO? WHAT TO DOOOO?"); }; } }
To add to that, I half-blindly tried the following hoping it would give some results but I get exceptions due to wrong type being given: Code (CSharp): // does it send one TouchControl value? (Error: TValue must be non-nullable) arInputActions.TouchActions.TouchPress.performed += _ => { Debug.Log(_.ReadValue<TouchControl>().touchId); } // does it send one touch at a time? (Runtime errors) arInputActions.TouchActions.TouchPress.performed += _ => { Debug.Log("Touch #: " + ((TouchControl)_.ReadValueAsObject()).touchId); }; // does it send all touches at once? (Runtime errors) arInputActions.TouchActions.TouchPress.performed += _ => { Debug.Log("N Touches: " + _.ReadValue<ReadOnlyArray<TouchControl>>().Count); }; (Read the "_" as context) In particular, I expected ReadValue<TouchControl> to work but the method wants a non-nullable type so TouchControl isn't accepted.