Ejemplo n.º 1
0
        protected virtual void SetTrackedControllerCaches(bool forceRefresh = false)
        {
            if (settingCaches)
            {
                return;
            }

            settingCaches = true;

            if (forceRefresh)
            {
                cachedLeftController  = null;
                cachedRightController = null;
            }

            VRTK_SDKManager sdkManager = VRTK_SDKManager.instance;

            if (sdkManager != null && sdkManager.loadedSetup != null)
            {
                if (cachedLeftController == null && sdkManager.loadedSetup.actualLeftController != null)
                {
                    cachedLeftController = sdkManager.loadedSetup.actualLeftController.GetComponent <VRTK_TrackedController>();
                    SetControllerIndex(ref cachedLeftController);
                    if (cachedLeftController != null)
                    {
                        cachedLeftTracker           = cachedLeftController.GetComponent <SDK_UnityControllerTracker>();
                        cachedLeftVelocityEstimator = cachedLeftController.GetComponent <VRTK_VelocityEstimator>();
                        SetControllerButtons(ControllerHand.Left);
                    }
                }
                if (cachedRightController == null && sdkManager.loadedSetup.actualRightController != null)
                {
                    cachedRightController = sdkManager.loadedSetup.actualRightController.GetComponent <VRTK_TrackedController>();
                    SetControllerIndex(ref cachedRightController);
                    if (cachedRightController != null)
                    {
                        cachedRightTracker           = cachedRightController.GetComponent <SDK_UnityControllerTracker>();
                        cachedRightVelocityEstimator = cachedRightController.GetComponent <VRTK_VelocityEstimator>();
                        SetControllerButtons(ControllerHand.Right);
                    }
                }
            }

            settingCaches = false;
        }
Ejemplo n.º 2
0
 protected virtual void SetControllerIndex(ref VRTK_TrackedController trackedController)
 {
     if (trackedController != null)
     {
         SDK_UnityControllerTracker tracker = trackedController.GetComponent <SDK_UnityControllerTracker>();
         if (tracker != null)
         {
             trackedController.index = tracker.index;
         }
     }
 }