美文网首页
Unity Pico Neo2监听手柄位置

Unity Pico Neo2监听手柄位置

作者: 114105lijia | 来源:发表于2022-05-30 15:43 被阅读0次

    我测试过,坐标原点应该在头显眼镜处。

    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 Pico Neo2监听手柄位置

          本文链接:https://www.haomeiwen.com/subject/uvvoprtx.html