Exemple #1
0
        // Token: 0x06001B67 RID: 7015 RVA: 0x0008F410 File Offset: 0x0008D610
        public void OnLoaded(VRTK_SDKManager sender)
        {
            List <SDK_Base> list = new SDK_Base[]
            {
                this.systemSDK,
                this.boundariesSDK,
                this.headsetSDK,
                this.controllerSDK
            }.ToList <SDK_Base>();

            list.ForEach(delegate(SDK_Base sdkBase)
            {
                sdkBase.OnBeforeSetupLoad(this);
            });
            base.gameObject.SetActive(true);
            VRTK_SDK_Bridge.InvalidateCaches();
            this.SetupHeadset();
            this.SetupControllers();
            this.boundariesSDK.InitBoundaries();
            list.ForEach(delegate(SDK_Base sdkBase)
            {
                sdkBase.OnAfterSetupLoad(this);
            });
            VRTK_SDKSetup.LoadEventHandler loaded = this.Loaded;
            if (loaded != null)
            {
                loaded(sender, this);
            }
        }
Exemple #2
0
        /// <summary>
        /// Populates the object references by using the currently set SDKs.
        /// </summary>
        /// <param name="force">Whether to ignore <see cref="autoPopulateObjectReferences"/> while deciding to populate.</param>
        public void PopulateObjectReferences(bool force)
        {
            if (!(force || autoPopulateObjectReferences))
            {
                return;
            }

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                VRTK_SDKManager.instance.SetLoadedSDKSetupToPopulateObjectReferences(this);
            }
#endif
            VRTK_SDK_Bridge.InvalidateCaches();

            actualBoundaries          = null;
            actualHeadset             = null;
            actualLeftController      = null;
            actualRightController     = null;
            modelAliasLeftController  = null;
            modelAliasRightController = null;

            Transform playAreaTransform = boundariesSDK.GetPlayArea();
            Transform headsetTransform  = headsetSDK.GetHeadset();

            actualBoundaries          = playAreaTransform == null ? null : playAreaTransform.gameObject;
            actualHeadset             = headsetTransform == null ? null : headsetTransform.gameObject;
            actualLeftController      = controllerSDK.GetControllerLeftHand(true);
            actualRightController     = controllerSDK.GetControllerRightHand(true);
            modelAliasLeftController  = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Left);
            modelAliasRightController = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Right);
        }
Exemple #3
0
        private void CreateInstance()
        {
            if (_instance == null)
            {
                _instance = this;
                VRTK_SDK_Bridge.InvalidateCaches();

                if (persistOnLoad && Application.isPlaying)
                {
                    DontDestroyOnLoad(gameObject);
                }
            }
            else if (_instance != this)
            {
                Destroy(gameObject);
            }
        }
Exemple #4
0
 // Token: 0x06001B4B RID: 6987 RVA: 0x0008E95C File Offset: 0x0008CB5C
 private void CreateInstance()
 {
     if (VRTK_SDKManager._instance == null)
     {
         VRTK_SDKManager._instance = this;
         VRTK_SDK_Bridge.InvalidateCaches();
         if (this.persistOnLoad && Application.isPlaying)
         {
             Object.DontDestroyOnLoad(base.gameObject);
             return;
         }
     }
     else if (VRTK_SDKManager._instance != this)
     {
         Object.Destroy(base.gameObject);
     }
 }
Exemple #5
0
        /// <summary>
        /// The OnLoaded method determines when an SDK Setup has been loaded.
        /// </summary>
        /// <param name="sender">The SDK Manager that has loaded the SDK Setup.</param>
        public void OnLoaded(VRTK_SDKManager sender)
        {
            List <SDK_Base> sdkBases = new SDK_Base[] { systemSDK, boundariesSDK, headsetSDK, controllerSDK }.ToList();

            sdkBases.ForEach(sdkBase => sdkBase.OnBeforeSetupLoad(this));

            gameObject.SetActive(true);
            VRTK_SDK_Bridge.InvalidateCaches();
            SetupHeadset();
            SetupControllers();
            boundariesSDK.InitBoundaries();

            sdkBases.ForEach(sdkBase => sdkBase.OnAfterSetupLoad(this));

            LoadEventHandler handler = Loaded;

            if (handler != null)
            {
                handler(sender, this);
            }
        }
Exemple #6
0
        // Token: 0x06001B65 RID: 7013 RVA: 0x0008F204 File Offset: 0x0008D404
        public void PopulateObjectReferences(bool force)
        {
            if (!force && !this.autoPopulateObjectReferences)
            {
                return;
            }
            VRTK_SDK_Bridge.InvalidateCaches();
            this.actualBoundaries          = null;
            this.actualHeadset             = null;
            this.actualLeftController      = null;
            this.actualRightController     = null;
            this.modelAliasLeftController  = null;
            this.modelAliasRightController = null;
            Transform playArea = this.boundariesSDK.GetPlayArea();
            Transform headset  = this.headsetSDK.GetHeadset();

            this.actualBoundaries          = ((playArea == null) ? null : playArea.gameObject);
            this.actualHeadset             = ((headset == null) ? null : headset.gameObject);
            this.actualLeftController      = this.controllerSDK.GetControllerLeftHand(true);
            this.actualRightController     = this.controllerSDK.GetControllerRightHand(true);
            this.modelAliasLeftController  = this.controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Left);
            this.modelAliasRightController = this.controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Right);
        }
Exemple #7
0
        private void CreateInstance()
        {
            if (_instance == null)
            {
                _instance = this;
                VRTK_SDK_Bridge.InvalidateCaches();

                string sdkErrorDescriptions = string.Join("\n- ", GetSimplifiedSDKErrorDescriptions());
                if (!string.IsNullOrEmpty(sdkErrorDescriptions))
                {
                    sdkErrorDescriptions = "- " + sdkErrorDescriptions;
                    Debug.LogError("There are some errors because of the current SDK Manager setup:\n" + sdkErrorDescriptions);
                }

                if (persistOnLoad && !VRTK_SharedMethods.IsEditTime())
                {
                    DontDestroyOnLoad(gameObject);
                }
            }
            else if (_instance != this)
            {
                Destroy(gameObject);
            }
        }
Exemple #8
0
        private void CreateInstance()
        {
            if (_instance == null)
            {
                _instance = this;
                VRTK_SDK_Bridge.InvalidateCaches();

                string sdkErrorDescriptions = string.Join("\n- ", GetSimplifiedSDKErrorDescriptions());
                if (!string.IsNullOrEmpty(sdkErrorDescriptions))
                {
                    sdkErrorDescriptions = "- " + sdkErrorDescriptions;
                    VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_MANAGER_ERRORS, new string[] { sdkErrorDescriptions }));
                }

                if (persistOnLoad && !VRTK_SharedMethods.IsEditTime())
                {
                    DontDestroyOnLoad(gameObject);
                }
            }
            else if (_instance != this)
            {
                Destroy(gameObject);
            }
        }
        /// <summary>
        /// The PopulateObjectReferences method populates the object references by using the currently set SDKs.
        /// </summary>
        /// <param name="force">Whether to ignore `autoPopulateObjectReferences` while deciding to populate.</param>
        public void PopulateObjectReferences(bool force)
        {
            if (!(force || autoPopulateObjectReferences))
            {
                return;
            }

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying && VRTK_SDKManager.ValidInstance())
            {
                VRTK_SDKManager.instance.SetLoadedSDKSetupToPopulateObjectReferences(this);
            }
#endif
            VRTK_SDK_Bridge.InvalidateCaches();

#if UNITY_EDITOR
            Undo.RecordObject(this, "Populate Object References");
#endif

            actualBoundaries          = null;
            actualHeadset             = null;
            actualLeftController      = null;
            actualRightController     = null;
            modelAliasLeftController  = null;
            modelAliasRightController = null;
            actualTrackers            = new List <GameObject>();
            actualHand = null;

            Transform playAreaTransform = boundariesSDK.GetPlayArea();
            Transform headsetTransform  = headsetSDK.GetHeadset();
            Transform handTransform     = handSDK.GetRootTransform();

            actualBoundaries          = playAreaTransform == null ? null : playAreaTransform.gameObject;
            actualHeadset             = headsetTransform == null ? null : headsetTransform.gameObject;
            actualLeftController      = controllerSDK.GetControllerLeftHand(true);
            actualRightController     = controllerSDK.GetControllerRightHand(true);
            actualHand                = handTransform == null ? null : handTransform.gameObject;
            modelAliasLeftController  = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Left);
            modelAliasRightController = controllerSDK.GetControllerModel(SDK_BaseController.ControllerHand.Right);

            GameObject[] trackerObjects = trackerSDK.GetAllTrackers();

            if (trackerObjects != null)
            {
                foreach (GameObject tracker in trackerObjects)
                {
                    if (!(tracker.Equals(actualHeadset) ||
                          tracker.Equals(actualLeftController) ||
                          tracker.Equals(actualRightController)
#if VRTK_DEFINE_STEAMVR_PLUGIN_2_0_0_OR_NEWER
                          || tracker.GetComponent <Valve.VR.SteamVR_TrackedObject>().index == Valve.VR.SteamVR_TrackedObject.EIndex.Hmd
#elif VRTK_DEFINE_SDK_STEAMVR
                          || tracker.GetComponent <SteamVR_TrackedObject>().index == SteamVR_TrackedObject.EIndex.Hmd
#endif
                          ))
                    {
                        // for now, we are not including HMDs or controllers in this list. We will revisit later, depending on the
                        // progress of gesture recognition and Oculus integration levels. See JIRA ticket VIRTUOSO-119 for details
                        actualTrackers.Add(tracker);
                    }
                }
            }
        }