コード例 #1
0
        /// <summary>
        /// Unloads the currently loaded <see cref="VRTK_SDKSetup"/>, if there is one.
        /// </summary>
        /// <param name="disableVR">Whether to disable VR altogether after unloading the SDK Setup.</param>
        public void UnloadSDKSetup(bool disableVR = true)
        {
            if (loadedSetup != null)
            {
                ToggleBehaviours(false);
            }

            VRTK_SDKSetup previousLoadedSetup = loadedSetup;

            loadedSetup = null;

            if (previousLoadedSetup != null)
            {
                previousLoadedSetup.OnUnloaded(this);
            }

            if (disableVR)
            {
                UnityEngine.XR.XRSettings.LoadDeviceByName("None");
                UnityEngine.XR.XRSettings.enabled = false;
            }

            if (previousLoadedSetup != null)
            {
                OnLoadedSetupChanged(new LoadedSetupChangeEventArgs(previousLoadedSetup, null, null));
            }
        }
コード例 #2
0
        // Token: 0x06001B47 RID: 6983 RVA: 0x0008E7CC File Offset: 0x0008C9CC
        public void UnloadSDKSetup(bool disableVR = false)
        {
            if (this.loadedSetup != null)
            {
                this.ToggleBehaviours(false);
            }
            VRTK_SDKSetup loadedSetup = this.loadedSetup;

            this.loadedSetup = null;
            if (loadedSetup != null)
            {
                loadedSetup.OnUnloaded(this);
            }
            if (disableVR)
            {
                XRSettings.LoadDeviceByName("None");
                XRSettings.enabled = false;
            }
            if (loadedSetup != null)
            {
                this.OnLoadedSetupChanged(new VRTK_SDKManager.LoadedSetupChangeEventArgs(loadedSetup, null, null));
            }
            VRTK_SDKManager._previouslyUsedSetupInfos.Clear();
            if (loadedSetup != null)
            {
                VRTK_SDKManager._previouslyUsedSetupInfos.UnionWith(new VRTK_SDKInfo[]
                {
                    loadedSetup.systemSDKInfo,
                    loadedSetup.boundariesSDKInfo,
                    loadedSetup.headsetSDKInfo,
                    loadedSetup.controllerSDKInfo
                });
            }
        }
コード例 #3
0
        // Token: 0x06001B46 RID: 6982 RVA: 0x0008E558 File Offset: 0x0008C758
        public void TryLoadSDKSetup(int startIndex, bool tryToReinitialize, params VRTK_SDKSetup[] sdkSetups)
        {
            if (sdkSetups.Length == 0)
            {
                return;
            }
            if (startIndex < 0 || startIndex >= sdkSetups.Length)
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("startIndex"));
                return;
            }
            sdkSetups = sdkSetups.ToList <VRTK_SDKSetup>().GetRange(startIndex, sdkSetups.Length - startIndex).ToArray();
            foreach (VRTK_SDKSetup vrtk_SDKSetup in from setup in sdkSetups
                     where !setup.isValid
                     select setup)
            {
                string text = string.Join("\n- ", vrtk_SDKSetup.GetSimplifiedErrorDescriptions());
                if (!string.IsNullOrEmpty(text))
                {
                    text = "- " + text;
                    VRTK_Logger.Warn(string.Format("Ignoring SDK Setup '{0}' because there are some errors with it:\n{1}", vrtk_SDKSetup.name, text));
                }
            }
            sdkSetups = (from setup in sdkSetups
                         where setup.isValid
                         select setup).ToArray <VRTK_SDKSetup>();
            VRTK_SDKSetup loadedSetup = this.loadedSetup;

            this.ToggleBehaviours(false);
            this.loadedSetup = null;
            if (loadedSetup != null)
            {
                loadedSetup.OnUnloaded(this);
            }
            if (!XRSettings.enabled || !sdkSetups[0].usedVRDeviceNames.Contains(XRSettings.loadedDeviceName))
            {
                if (!tryToReinitialize && !XRSettings.enabled && !string.IsNullOrEmpty(XRSettings.loadedDeviceName))
                {
                    sdkSetups = (from setup in sdkSetups
                                 where !setup.usedVRDeviceNames.Contains(XRSettings.loadedDeviceName)
                                 select setup).ToArray <VRTK_SDKSetup>();
                }
                VRTK_SDKSetup[] array = (from setup in sdkSetups
                                         where setup.usedVRDeviceNames.Except(XRSettings.supportedDevices).Any <string>()
                                         select setup).ToArray <VRTK_SDKSetup>();
                foreach (VRTK_SDKSetup vrtk_SDKSetup2 in array)
                {
                    string arg = string.Join(", ", vrtk_SDKSetup2.usedVRDeviceNames.Except(XRSettings.supportedDevices).ToArray <string>());
                    VRTK_Logger.Warn(string.Format("Ignoring SDK Setup '{0}' because the following VR device names are missing from the PlayerSettings:\n{1}", vrtk_SDKSetup2.name, arg));
                }
                sdkSetups = sdkSetups.Except(array).ToArray <VRTK_SDKSetup>();
                XRSettings.LoadDeviceByName(sdkSetups.SelectMany((VRTK_SDKSetup setup) => setup.usedVRDeviceNames).Distinct <string>().Concat(new string[]
                {
                    "None"
                }).ToArray <string>());
            }
            base.StartCoroutine(this.FinishSDKSetupLoading(sdkSetups, loadedSetup));
        }
コード例 #4
0
ファイル: VRTK_SDKManager.cs プロジェクト: cmvanb/VRJam2017
        /// <summary>
        /// Unloads the currently loaded <see cref="VRTK_SDKSetup"/>, if there is one.
        /// </summary>
        /// <param name="disableVR">Whether to disable VR altogether after unloading the SDK Setup.</param>
        public void UnloadSDKSetup(bool disableVR = false)
        {
            if (loadedSetup != null)
            {
                ToggleBehaviours(false);
            }

            VRTK_SDKSetup previousLoadedSetup = loadedSetup;

            loadedSetup = null;

            if (previousLoadedSetup != null)
            {
                previousLoadedSetup.OnUnloaded(this);
            }

            if (disableVR)
            {
                VRSettings.LoadDeviceByName("None");
                VRSettings.enabled = false;
            }

            if (previousLoadedSetup != null)
            {
                OnLoadedSetupChanged(new LoadedSetupChangeEventArgs(previousLoadedSetup, null, null));
            }

            _previouslyUsedSetupInfos.Clear();
            if (previousLoadedSetup != null)
            {
                _previouslyUsedSetupInfos.UnionWith(
                    new[]
                {
                    previousLoadedSetup.systemSDKInfo,
                    previousLoadedSetup.boundariesSDKInfo,
                    previousLoadedSetup.headsetSDKInfo,
                    previousLoadedSetup.controllerSDKInfo
                }
                    );
            }
        }
コード例 #5
0
        /// <summary>
        /// Tries to load a valid VRTK_SDKSetup from a list.
        /// </summary>
        /// <remarks>
        /// The first loadable VRTK_SDKSetup in the list will be loaded. Will fall back to disable VR if none of the provided Setups is useable.
        /// </remarks>
        /// <param name="startIndex">The index of the VRTK_SDKSetup to start the loading with.</param>
        /// <param name="tryToReinitialize">Whether or not to retry initializing and using the currently set but unusable VR Device.</param>
        /// <param name="sdkSetups">The list to try to load a VRTK_SDKSetup from.</param>
        public void TryLoadSDKSetup(int startIndex, bool tryToReinitialize, params VRTK_SDKSetup[] sdkSetups)
        {
            if (sdkSetups.Length == 0)
            {
                return;
            }

            if (startIndex < 0 || startIndex >= sdkSetups.Length)
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("startIndex"));
                return;
            }

            sdkSetups = sdkSetups.ToList()
                        .GetRange(startIndex, sdkSetups.Length - startIndex)
                        .ToArray();

            foreach (VRTK_SDKSetup invalidSetup in sdkSetups.Where(setup => !setup.isValid))
            {
                string setupErrorDescriptions = string.Join("\n- ", invalidSetup.GetSimplifiedErrorDescriptions());
                if (!string.IsNullOrEmpty(setupErrorDescriptions))
                {
                    setupErrorDescriptions = "- " + setupErrorDescriptions;
                    VRTK_Logger.Warn(string.Format("Ignoring SDK Setup '{0}' because there are some errors with it:\n{1}", invalidSetup.name, setupErrorDescriptions));
                }
            }

            sdkSetups = sdkSetups.Where(setup => setup.isValid).ToArray();

            VRTK_SDKSetup previousLoadedSetup = loadedSetup;

            ToggleBehaviours(false);
            loadedSetup = null;
            if (previousLoadedSetup != null)
            {
                previousLoadedSetup.OnUnloaded(this);
            }

            string loadedDeviceName      = string.IsNullOrEmpty(XRSettings.loadedDeviceName) ? "None" : XRSettings.loadedDeviceName;
            bool   isDeviceAlreadyLoaded = sdkSetups[0].usedVRDeviceNames.Contains(loadedDeviceName);

            if (!isDeviceAlreadyLoaded)
            {
                if (!tryToReinitialize && !XRSettings.enabled && loadedDeviceName != "None")
                {
                    sdkSetups = sdkSetups.Where(setup => !setup.usedVRDeviceNames.Contains(loadedDeviceName))
                                .ToArray();
                }

                VRTK_SDKSetup[] missingVRDeviceSetups = sdkSetups
                                                        .Where(setup => setup.usedVRDeviceNames.Except(XRSettings.supportedDevices.Concat(new[] { "None" })).Any())
                                                        .ToArray();
                foreach (VRTK_SDKSetup missingVRDeviceSetup in missingVRDeviceSetups)
                {
                    string missingVRDevicesText = string.Join(
                        ", ",
                        missingVRDeviceSetup.usedVRDeviceNames
                        .Except(XRSettings.supportedDevices)
                        .ToArray()
                        );
                    VRTK_Logger.Warn(string.Format("Ignoring SDK Setup '{0}' because the following VR device names are missing from the PlayerSettings:\n{1}",
                                                   missingVRDeviceSetup.name,
                                                   missingVRDevicesText));
                }

                sdkSetups = sdkSetups.Except(missingVRDeviceSetups).ToArray();
                string[] vrDeviceNames = sdkSetups
                                         .SelectMany(setup => setup.usedVRDeviceNames)
                                         .Distinct()
                                         .Concat(new[] { "None" }) // Add "None" to the end to fall back to
                                         .ToArray();
                XRSettings.LoadDeviceByName(vrDeviceNames);
            }

            StartCoroutine(FinishSDKSetupLoading(sdkSetups, previousLoadedSetup));
        }