找回密码
 立即注册
查看: 230|回复: 0

Unity Pico Neo2监听手柄位置

[复制链接]
发表于 2022-5-30 15:25 | 显示全部楼层 |阅读模式
我测试过,坐标原点应该在头显眼镜处。
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.XR;public class TestUI : MonoBehaviour{    public Transform targetTransform;    public Text text1, text2, text3;    Vector3 devicePosition;    private void Start()    {        devicePosition = Vector3.zero;        ShowPosition(devicePosition);    }    private void Update()    {        InputDevice rightHandController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);        if (rightHandController.TryGetFeatureValue(CommonUsages.devicePosition, out devicePosition)) {            ShowPosition(devicePosition);        }    }    void ShowPosition(Vector3 position) {        text1.text = position.x.ToString();        text2.text = position.y.ToString();        text3.text = position.z.ToString();    }}
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-6-3 06:25 , Processed in 0.087651 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表