Esempio n. 1
0
    void Update()
    {
        if (!util.IsReady())
        {
            util.Init();
            return;
        }

        var h = util.GetHMDTransform();

        if (h != null)
        {
            Head.transform.position = h.position;
            Head.transform.rotation = h.rotation;
        }

        //IPD取得してカメラに反映
        float IPD = util.GetPropertyFloatWhenConnected(util.GetHMDIndex(), Valve.VR.ETrackedDeviceProperty.Prop_UserIpdMeters_Float);

        if (!float.IsNaN(IPD))
        {
            LeftEye.transform.localPosition  = new Vector3(-IPD / 2f, 0, 0);
            RightEye.transform.localPosition = new Vector3(IPD / 2f, 0, 0);
        }

        var l = util.GetLeftControllerTransform();

        if (l != null)
        {
            LeftHand.transform.position = l.position;
            LeftHand.transform.rotation = l.rotation;
        }

        var r = util.GetRightControllerTransform();

        if (r != null)
        {
            RightHand.transform.position = r.position;
            RightHand.transform.rotation = r.rotation;
        }
    }