Hello.
I want to call an Input Action using a UI element directly through the Unity Input System. I encountered a problem because the Controls array will be empty on a mobile device because my Bindings array will be empty. How can I call InputAction through the Unity Input System so that I get performed in my code?
Here is my code:
[SerializeField] private InputActionReference actionReference;
public void OnPointerDown(PointerEventData eventData)
{
if (actionReference != null && actionReference.action != null)
{
var controls = actionReference.action.controls;
if (controls.Count > 0)
{
var control = controls[0];
var device = control.device;
using (StateEvent.From(device, out var eventPtr))
{
control.WriteValueIntoEvent(1.0f, eventPtr);
UnityEngine.InputSystem.InputSystem.QueueEvent(eventPtr);
}
}
}
}