Example #1
0
    public void UpdateHandler()
    {
        if (!SteamVRStartup())
        {
            return;
        }

        ovrHandler.UpdateAll();

        if (hmdObject)
        {
            poseHandler.SetTransformToTrackedDevice(hmdObject.transform, poseHandler.hmdIndex);
        }

        if (poseHandler.rightActive && rightTrackerObj)
        {
            rightTrackerObj.SetActive(true);
            poseHandler.SetTransformToTrackedDevice(rightTrackerObj.transform, poseHandler.rightIndex);
        }
        else if (rightTrackerObj)
        {
            rightTrackerObj.SetActive(false);
        }

        if (poseHandler.leftActive && leftTrackerObj)
        {
            leftTrackerObj.SetActive(true);
            poseHandler.SetTransformToTrackedDevice(leftTrackerObj.transform, poseHandler.leftIndex);
        }
        else if (leftTrackerObj)
        {
            leftTrackerObj.SetActive(false);
        }
    }
    public void UpdateHandler()
    {
        if (!SteamVRStartup())
        {
            return;
        }
        if (notCreated)
        {
            foreach (var index in ovrHandler.GetTrackers().Keys)
            {
                var newTracker = Instantiate(tracker);
                newTracker.steamVRHandlerPrefab = gameObject;
                newTracker.overlayKey           = $"tracker_obj_{index}";
                newTracker.customDeviceIndex    = (uint)index;
                newTracker.overlayTexture       = overlayTexture;
                newTracker.cameraForTexture     = TrackerCamera;
            }
            notCreated = false;
        }
        ovrHandler.UpdateAll();

        if (hmdObject)
        {
            poseHandler.SetTransformToTrackedDevice(hmdObject.transform, poseHandler.hmdIndex);
        }
        // Debug.Log(ovrHandler.VRSystem.GetControllerRoleForTrackedDeviceIndex(0));
        if (poseHandler.rightActive && rightTrackerObj)
        {
            rightTrackerObj.SetActive(true);
            poseHandler.SetTransformToTrackedDevice(rightTrackerObj.transform, poseHandler.rightIndex);
        }
        else if (rightTrackerObj)
        {
            rightTrackerObj.SetActive(false);
        }

        if (poseHandler.leftActive && leftTrackerObj)
        {
            leftTrackerObj.SetActive(true);
            poseHandler.SetTransformToTrackedDevice(leftTrackerObj.transform, poseHandler.leftIndex);
        }
        else if (leftTrackerObj)
        {
            leftTrackerObj.SetActive(false);
        }
    }
Example #3
0
    public void UpdateHandler()
    {
        if (!SteamVRStartup())
        {
            return;
        }

        ovrHandler.UpdateAll();

        if (lastDebugLog != debugLog)
        {
            ovrHandler.logDebug = debugLog;
            lastDebugLog        = debugLog;
        }

        if (hmdObject)
        {
            poseHandler.SetTransformToTrackedDevice(hmdObject.transform, poseHandler.hmdIndex);
        }

        if (!hmd_pos)
        {
            hmdObject.transform.position = Vector3.zero;
        }

        if (!hmd_rot)
        {
            hmdObject.transform.eulerAngles = Vector3.forward;
        }

        if (poseHandler.rightActive && rightTrackerObj)
        {
            if (!rightTrackerObj.activeSelf)
            {
                rightTrackerObj.SetActive(true);
            }

            poseHandler.SetTransformToTrackedDevice(rightTrackerObj.transform, poseHandler.rightIndex);

            if (!right_pos)
            {
                rightTrackerObj.transform.position = Vector3.zero;
            }

            if (!right_rot)
            {
                rightTrackerObj.transform.eulerAngles = Vector3.forward;
            }
        }
        else if (rightTrackerObj)
        {
            rightTrackerObj.SetActive(false);
        }

        if (poseHandler.leftActive && leftTrackerObj)
        {
            if (!leftTrackerObj.activeSelf)
            {
                leftTrackerObj.SetActive(true);
            }

            poseHandler.SetTransformToTrackedDevice(leftTrackerObj.transform, poseHandler.leftIndex);

            if (!left_pos)
            {
                leftTrackerObj.transform.position = Vector3.zero;
            }

            if (!left_rot)
            {
                leftTrackerObj.transform.eulerAngles = Vector3.forward;
            }
        }
        else if (leftTrackerObj)
        {
            leftTrackerObj.SetActive(false);
        }
    }