position - 如何在 Hololens 上获得手的位置?
问题描述
我有这个脚本是为了用 hololens 获得手的位置,但它不起作用,它给了我这个错误:Errore CS0123 Nessun 过载 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)
推荐阅读
- php - 如何将 laravel 刀片嵌入到 wordpress 项目中?
- python - 我必须在哪里将 test_*.py 文件放在 Django 中?
- sql - 将存在查询的结果保存到变量
- uno-platform - 在 Windows 10 上安装 uno 平台
- sql-server - 使用多个连接,可以将一个特定列的行转为一行而不是转为列吗?
- microsoft-graph-api - 如何从日历中列出所有重复会议
- angular - 如何访问嵌入在 ng-template 中的组件?
- haskell-stack - Haskell 中的堆栈构建
- c++ - Noexcept 可变参数 is_nothrow_constructible_v
- javascript - 扩展另一个接口时获取基本接口