I have this script in order to get hand position with hololens, but it does not work and it gives me this error: Errore CS0123 Nessun overload per 'GetPosition' corrisponde al delegato 'Action' Can someone help me ?
This is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.WSA.Input;
public class Hand : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void Awake()
{
InteractionManager.InteractionSourcePressed += GetPosition; // No overload for 'GetPosition' corresponds to delegate 'Action<InteractionSourcePressedEventArgs>'
}
private void GetPosition(InteractionSourceState state)
{
Vector3 pos;
if (state.sourcePose.TryGetPosition(out pos))
{
Debug.Log(pos);
}
}
}
The error code pointed out that if you want to register for the InteractionSourcePressed
input event, you should modify the callback function GetPosition
to match the delegate of the InteractionSourcePressed
event.
So, in this case, you can refer to the following code to fix this issue:
private void GetPosition(InteractionSourceState state)
=>
private void GetPosition(InteractionSourcePressedEventArgs args)
More information please see:Windows-specific APIs (XR.WSA.Input)