Пример #1
0
 protected virtual void SetCaches()
 {
     if (cachedVelocityEstimator == null)
     {
         cachedVelocityEstimator = (GetComponent <VRTK_VelocityEstimator>() != null ? GetComponent <VRTK_VelocityEstimator>() : gameObject.AddComponent <VRTK_VelocityEstimator>());
     }
 }
Пример #2
0
        protected virtual void SetHeadsetCaches()
        {
            Transform currentHeadset = GetHeadset();

            if (cachedHeadsetVelocityEstimator == null && currentHeadset != null)
            {
                cachedHeadsetVelocityEstimator = currentHeadset.GetComponent <VRTK_VelocityEstimator>();
            }
        }
Пример #3
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;
        }