Beispiel #1
0
        void DetectOpenXRSetup(out bool APIDetectedRuntime, out bool VRDeviceDisconnected)
        {
            // 0.0.0 is the default value when no device is connected, or when no Krhonos registry ActiveRuntime key is provided
            APIDetectedRuntime   = !OpenXRRuntime.version.Equals("0.0.0");
            VRDeviceDisconnected = false;

            var enabledExtensions = string.Join(",", OpenXRRuntime.GetEnabledExtensions());

            Debug.Log($"OPENXR API detected Capabilities: {OpenXRRuntime.name}, {OpenXRRuntime.apiVersion}, {OpenXRRuntime.pluginVersion}, {OpenXRRuntime.version}, {enabledExtensions}");

#if UNITY_STANDALONE_WIN
            // Lets see if we can differantiate a disconnected device from a missing OpenXR setup
            if (!APIDetectedRuntime)
            {
                // Best effort detection as accessing LocalMachine registry key hive can be denied for security
                try
                {
                    using (var reflectKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Khronos\\OpenXR\\1"))
                    {
                        var detectedActiveRuntimeJson = reflectKey.GetValue("ActiveRuntime");
                        if (detectedActiveRuntimeJson != null && File.Exists(detectedActiveRuntimeJson.ToString()))
                        {
                            VRDeviceDisconnected = true;
                        }
                    }
                }
                catch (Exception) { }
            }
#endif
        }
        /// <inheritdoc/>
        protected internal override bool OnInstanceCreate(ulong instance)
        {
            // Requires the eye tracking extension
            if (!OpenXRRuntime.IsExtensionEnabled(extensionString))
            {
                return(false);
            }

            return(base.OnInstanceCreate(instance));
        }
Beispiel #3
0
        public IEnumerator CheckSpecExtensionEnabled()
        {
            MockRuntime.Instance.openxrExtensionStrings = MockRuntime.XR_UNITY_mock_test;

            base.InitializeAndStart();

            yield return(null);

            Assert.AreEqual(true, OpenXRRuntime.IsExtensionEnabled(MockRuntime.XR_UNITY_mock_test));
        }
Beispiel #4
0
        public IEnumerator CheckSpecExtensionVersion()
        {
            AddExtension(MockRuntime.XR_UNITY_mock_test);

            base.InitializeAndStart();

            yield return(null);

            Assert.AreEqual(123, OpenXRRuntime.GetExtensionVersion(MockRuntime.XR_UNITY_mock_test));
        }
Beispiel #5
0
        /// <inheritdoc />
        protected override bool OnInstanceCreate(ulong instance)
        {
            if (!OpenXRRuntime.IsExtensionEnabled("XR_UNITY_mock_driver"))
            {
                Debug.LogWarning("XR_UNITY_mock_driver is not enabled, disabling Mock Driver.");
                return(false);
            }

            InitializeNative(xrGetInstanceProcAddr, instance, 0ul, 0ul);
            return(true);
        }
Beispiel #6
0
        /// <inheritdoc/>
        protected internal override bool OnInstanceCreate(ulong instance)
        {
            if (!OpenXRRuntime.IsExtensionEnabled("XR_EXT_conformance_automation"))
            {
                Debug.LogError("XR_EXT_conformance_automation is not enabled. Disabling ConformanceAutomationExt");
                return(false);
            }

            xrInstance = instance;
            xrSession  = 0ul;

            initialize(xrGetInstanceProcAddr, xrInstance);
            return(true);
        }
        public virtual void BeforeTest()
        {
            // Make sure we are not running
            if (OpenXRLoaderBase.Instance != null)
            {
                StopAndShutdown();
            }

            // Cache off the features before we start
            savedFeatures = (OpenXRFeature[])OpenXRSettings.Instance.features.Clone();

            // Disable all features to make sure the feature list is clean before tests start.
            DisableAllFeatures();

            // Enable the mock runtime and reset it back to default state
            Assert.IsTrue(EnableMockRuntime());
            MockRuntime.ResetDefaults();
            OpenXRRuntime.ClearEvents();
            OpenXRRestarter.Instance.ResetCallbacks();

#pragma warning disable CS0618
            loader = XRGeneralSettings.Instance?.Manager?.loaders[0] as OpenXRLoader;
#pragma warning restore CS0618
        }
Beispiel #8
0
        public IEnumerator CheckSpecExtensionEnabledAtXrInstanceCreated()
        {
            AddExtension(MockRuntime.XR_UNITY_mock_test);

            bool xrCreateInstanceCalled = false;
            bool containsMockExt        = false;

            MockRuntime.Instance.TestCallback = (methodName, param) =>
            {
                if (methodName == nameof(OpenXRFeature.OnInstanceCreate))
                {
                    containsMockExt        = OpenXRRuntime.IsExtensionEnabled(MockRuntime.XR_UNITY_mock_test);
                    xrCreateInstanceCalled = true;
                }

                return(true);
            };

            base.InitializeAndStart();
            yield return(null);

            Assert.IsTrue(xrCreateInstanceCalled);
            Assert.IsTrue(containsMockExt);
        }