如何在 Hololens 上获得手的位置?
How to get hand position on Hololens?
我有这个脚本是为了用全息镜头获得手的位置,但它不起作用,它给了我这个错误:
Errore CS0123 Nessun overload per 'GetPosition' corrisponde al delegato 'Action'
有人可以帮助我吗?
这是代码:
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);
}
}
}
错误码指出如果要注册InteractionSourcePressed
输入事件,需要修改回调函数GetPosition
匹配InteractionSourcePressed
事件的委托。
所以,在这种情况下,您可以参考下面的代码来解决这个问题:
private void GetPosition(InteractionSourceState state)
=>
private void GetPosition(InteractionSourcePressedEventArgs args)
更多信息请参阅:Windows-特定 API (XR.WSA.Input)
我有这个脚本是为了用全息镜头获得手的位置,但它不起作用,它给了我这个错误: Errore CS0123 Nessun overload per 'GetPosition' corrisponde al delegato 'Action' 有人可以帮助我吗?
这是代码:
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);
}
}
}
错误码指出如果要注册InteractionSourcePressed
输入事件,需要修改回调函数GetPosition
匹配InteractionSourcePressed
事件的委托。
所以,在这种情况下,您可以参考下面的代码来解决这个问题:
private void GetPosition(InteractionSourceState state)
=>
private void GetPosition(InteractionSourcePressedEventArgs args)
更多信息请参阅:Windows-特定 API (XR.WSA.Input)