/// <summary>
        /// Only for internal use.
        /// </summary>
        /// <returns></returns>
        public static List <AdaptivePerformanceSubsystemDescriptor> GetRegisteredDescriptors()
        {
            var perfDescriptors = new List <AdaptivePerformanceSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors <AdaptivePerformanceSubsystemDescriptor>(perfDescriptors);
            return(perfDescriptors);
        }
Пример #2
0
        /// <summary>
        /// Creates a subsystem given a list of descriptors and a specific subsystem id.
        /// </summary>
        ///
        /// <typeparam name="TDescriptor">The descriptor type being passed in.</typeparam>
        /// <typeparam name="TSubsystem">The subsystem type being requested</typeparam>
        /// <param name="descriptors">List of TDescriptor instances to use for subsystem matching.</param>
        /// <param name="id">The identifier key of the particualr subsystem implementation being requested.</param>
        protected void CreateSubsystem <TDescriptor, TSubsystem>(List <TDescriptor> descriptors, string id)
            where TDescriptor : ISubsystemDescriptor
            where TSubsystem : ISubsystem
        {
            if (descriptors == null)
            {
                throw new ArgumentNullException("descriptors");
            }

            SubsystemManager.GetSubsystemDescriptors <TDescriptor>(descriptors);

            if (descriptors.Count > 0)
            {
                foreach (var descriptor in descriptors)
                {
                    ISubsystem subsys = null;
                    if (String.Compare(descriptor.id, id, true) == 0)
                    {
                        subsys = descriptor.Create();
                    }
                    if (subsys != null)
                    {
                        m_SubsystemInstanceMap[typeof(TSubsystem)] = subsys;
                        break;
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a subsystem given a specific subsystem id.
        /// </summary>
        /// <param name="id">The identifier key of the particular subsystem implementation being requested.</param>
        protected bool CreateSubsystem(string id)
        {
            Register();

            List <TDescriptor> descriptors = new List <TDescriptor>();

            // load all available descriptors with type TDescriptor from SubsystemManager.
            SubsystemManager.GetSubsystemDescriptors(descriptors);

            if (descriptors.Count > 0)
            {
                foreach (var descriptor in descriptors)
                {
                    ISubsystem subsys = null;
                    if (string.Compare(descriptor.id, id, true) == 0)
                    {
                        subsys = descriptor.Create();
                    }
                    if (subsys != null)
                    {
                        m_SubsystemInstanceMap[typeof(T)] = subsys;
                        m_Subsystem           = subsys as T;
                        m_SubsystemDescriptor = descriptor;
                        break;
                    }
                }
            }

            if (m_Subsystem == null)
            {
                Utils.Logger.Error("Failed to load subsystem: " + id);
            }

            return(m_Subsystem != null);
        }
Пример #4
0
        private static XRReferencePointSubsystemDescriptor GetSubsystemDescriptor()
        {
            List <XRReferencePointSubsystemDescriptor> descriptors = new List <XRReferencePointSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(descriptors);
            return(descriptors.FirstOrDefault(d => d.id != ID));
        }
Пример #5
0
        static TSubsystem CreateSubsystem <TDescriptor, TSubsystem>(List <TDescriptor> descriptors, string id = null)
            where TDescriptor : SubsystemDescriptor <TSubsystem>
            where TSubsystem : Subsystem <TDescriptor>
#endif
        {
            SubsystemManager.GetSubsystemDescriptors <TDescriptor>(descriptors);
            if (descriptors.Count > 0)
            {
                if (!string.IsNullOrEmpty(id))
                {
                    foreach (TDescriptor descriptor in descriptors)
                    {
                        if (descriptor.id.IndexOf(id, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            return(descriptor.Create());
                        }
                    }
                }
                else
                {
                    TDescriptor descriptor = descriptors[0];
                    if (descriptors.Count > 1)
                    {
                        System.Type type = typeof(TDescriptor);
                        Debug.LogWarningFormat("Found {0} {1}s. Using \"{2}\"", (object)descriptors.Count, (object)type.Name, (object)descriptor.id);
                    }
                    return(descriptor.Create());
                }
            }
            return((TSubsystem)null);
        }
Пример #6
0
        public void OnEnable()
        {
            settings.OnEnable();

            var c = (Camera)target;

            m_ShowBGColorOptions.value  = !clearFlagsHasMultipleValues && (c.clearFlags == CameraClearFlags.SolidColor || c.clearFlags == CameraClearFlags.Skybox);
            m_ShowOrthoOptions.value    = c.orthographic;
            m_ShowTargetEyeOption.value = targetEyeValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported;

            m_ShowBGColorOptions.valueChanged.AddListener(Repaint);
            m_ShowOrthoOptions.valueChanged.AddListener(Repaint);
            m_ShowTargetEyeOption.valueChanged.AddListener(Repaint);

            SubsystemManager.GetSubsystemDescriptors(displayDescriptors);
            SubsystemManager.reloadSubsytemsCompleted += OnReloadSubsystemsComplete;

            SceneView.duringSceneGui += DuringSceneGUI;

            foreach (var camera in targets)
            {
                m_OverlayWindows[(Camera)camera] = new OverlayWindow(new GUIContent(camera.name), OnOverlayGUI,
                                                                     (int)SceneViewOverlay.Ordering.Camera, camera,
                                                                     SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget);
            }
        }
Пример #7
0
    bool IsActive()
    {
        displaysDescs.Clear();
        SubsystemManager.GetSubsystemDescriptors(displaysDescs);

        // If there are registered display descriptors that is a good indication that VR is most likely "enabled"
        return(displaysDescs.Count > 0);
    }
Пример #8
0
        /// <inheritdoc />
        public bool CheckCapability(MixedRealityCapability capability)
        {
            if (capability != MixedRealityCapability.SpatialAwarenessMesh)
            {
                return(false);
            }

            var descriptors = new List <XRMeshSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(descriptors);

            return(descriptors.Count > 0);
        }
Пример #9
0
        static XRTestSubsystem RegisterAndCreate()
        {
            SubsystemRegistration.CreateDescriptor(new XRTestSubsystemDescriptor
            {
                id = "Test Subsystem",
                subsystemImplementationType = typeof(XRTestSubsystem),
            });

            var descriptors = new List <XRTestSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors <XRTestSubsystemDescriptor>(descriptors);
            return(descriptors[0].Create());
        }
        static void Register()
        {
            List <XRSessionSubsystemDescriptor> sessionSubsystemDescriptors = new List <XRSessionSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(sessionSubsystemDescriptors);
            if (sessionSubsystemDescriptors.Count > 0)
            {
                UnityXRMockSessionSubsystem.RegisterDescriptor(sessionSubsystemDescriptors[0]);
            }
            else
            {
                UnityXRMockSessionSubsystem.RegisterDescriptor();
            }
        }
Пример #11
0
        static void Register()
        {
            List <XRPlaneSubsystemDescriptor> planeSubsystemDescriptors = new List <XRPlaneSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(planeSubsystemDescriptors);
            if (planeSubsystemDescriptors.Count > 0)
            {
                UnityXRMockPlaneProvider.RegisterDescriptor(planeSubsystemDescriptors[0], GetTrackingState);
            }
            else
            {
                UnityXRMockPlaneProvider.RegisterDescriptor(null, GetTrackingState);
            }
        }
Пример #12
0
        static void Register()
        {
            List <XRReferencePointSubsystemDescriptor> referencePointSubsystemDescriptors = new List <XRReferencePointSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(referencePointSubsystemDescriptors);
            if (referencePointSubsystemDescriptors.Count > 0)
            {
                UnityXRMockReferencePointSubsystem.RegisterDescriptor(referencePointSubsystemDescriptors[0], AttachReferencePoint);
            }
            else
            {
                UnityXRMockReferencePointSubsystem.RegisterDescriptor(null, AttachReferencePoint);
            }
        }
        static void Register()
        {
            List <XRRaycastSubsystemDescriptor> raycastSubsystemDescriptors = new List <XRRaycastSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(raycastSubsystemDescriptors);
            if (raycastSubsystemDescriptors.Count > 0)
            {
                UnityXRMockRaycastSubsytem.RegisterDescriptor(raycastSubsystemDescriptors[0]);
            }
            else
            {
                UnityXRMockRaycastSubsytem.RegisterDescriptor(null);
            }
        }
        static void ListSessions()
        {
            var descriptors = new List <XRSessionSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(descriptors);
            foreach (var descriptor in descriptors)
            {
                Debug.LogFormat("Session: {0}", descriptor.id);
            }

            if (descriptors.Count == 0)
            {
                Debug.Log("No sessions available.");
            }
        }
Пример #15
0
        static void ListSessions()
        {
            var descriptors = new List <XRSessionSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(descriptors);
            foreach (var descriptor in descriptors)
            {
                Debug.unityLogger.Log("ar-mock", $"Session: {descriptor.id}");
            }

            if (descriptors.Count == 0)
            {
                Debug.unityLogger.Log("ar-mock", "No sessions available.");
            }
        }
        bool SubsystemDescriptorRegistered <T>(string id) where T : SubsystemDescriptor
        {
            List <T> descriptors = new List <T>();

            SubsystemManager.GetSubsystemDescriptors <T>(descriptors);

            foreach (T descriptor in descriptors)
            {
                if (descriptor.id == id)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void UseSubsystemTest()
        {
            List <TestSubsystemDescriptor> descriptors = new List <TestSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors <TestSubsystemDescriptor>(descriptors);
            Assert.That(1 == descriptors.Count, "TestSubsystemDescriptor not registered.");

            Assert.That("RuntimeTestSubsystem" == descriptors[0].id, "Subsystem ID doesn't match registered ID.");

            TestSubsystem subsystem = descriptors[0].Create();

            Assert.That(null != subsystem, "Create() failed in test subsystem descriptor.");

            // Method call works
            Assert.That(66 == subsystem.GetNumThings(), "Test method on TestSubsystem failed.");
        }
Пример #18
0
        public void OnEnable()
        {
            settings.OnEnable();

            var c = (Camera)target;

            m_ShowBGColorOptions.value  = !clearFlagsHasMultipleValues && (c.clearFlags == CameraClearFlags.SolidColor || c.clearFlags == CameraClearFlags.Skybox);
            m_ShowOrthoOptions.value    = c.orthographic;
            m_ShowTargetEyeOption.value = targetEyeValue != (int)StereoTargetEyeMask.Both || VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            m_ShowBGColorOptions.valueChanged.AddListener(Repaint);
            m_ShowOrthoOptions.valueChanged.AddListener(Repaint);
            m_ShowTargetEyeOption.valueChanged.AddListener(Repaint);

            SubsystemManager.GetSubsystemDescriptors(displayDescriptors);
            SubsystemManager.afterReloadSubsystems += OnReloadSubsystemsComplete;
        }
Пример #19
0
        public void OnEnable()
        {
            settings.OnEnable();

            var c = (Camera)target;

            m_ShowBGColorOptions.value  = !clearFlagsHasMultipleValues && (c.clearFlags == CameraClearFlags.SolidColor || c.clearFlags == CameraClearFlags.Skybox);
            m_ShowOrthoOptions.value    = c.orthographic;
            m_ShowTargetEyeOption.value = targetEyeValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported;

            m_ShowBGColorOptions.valueChanged.AddListener(Repaint);
            m_ShowOrthoOptions.valueChanged.AddListener(Repaint);
            m_ShowTargetEyeOption.valueChanged.AddListener(Repaint);

            SubsystemManager.GetSubsystemDescriptors(displayDescriptors);
            SubsystemManager.reloadSubsytemsCompleted += OnReloadSubsystemsComplete;
        }
Пример #20
0
        XRMeshSubsystem CreateSubsystem()
        {
            SubsystemManager.GetSubsystemDescriptors(s_SubsystemDescriptors);
            if (s_SubsystemDescriptors.Count > 0)
            {
                var descriptor = s_SubsystemDescriptors[0];
                if (s_SubsystemDescriptors.Count > 1)
                {
                    Debug.LogWarning($"Multiple {nameof(XRMeshSubsystem)} found. Using {descriptor.id}");
                }

                return(descriptor.Create());
            }
            else
            {
                return(null);
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            if (!Application.isPlaying || Application.isEditor || meshSubsystem != null)
            {
                return;
            }

            descriptors.Clear();
            SubsystemManager.GetSubsystemDescriptors(descriptors);

            if (descriptors.Count > 0)
            {
                var descriptorToUse = descriptors[0];

                if (descriptors.Count > 1)
                {
                    var typeOfD = typeof(XRMeshSubsystemDescriptor);
                    Debug.LogWarning($"Found {descriptors.Count} {typeOfD.Name}s. Using \"{descriptorToUse.id}\"");
                }

                meshSubsystem = descriptorToUse.Create();
            }

            if (meshSubsystem == null)
            {
                throw new Exception("Failed to start Lumin Mesh Subsystem!");
            }

            LuminApi.UnityMagicLeap_MeshingSetBatchSize(16);
            var levelOfDetail = MLSpatialMapper.LevelOfDetail.Medium;

            if (MeshLevelOfDetail == SpatialAwarenessMeshLevelOfDetail.Fine)
            {
                levelOfDetail = MLSpatialMapper.LevelOfDetail.Maximum;
            }

            LuminApi.UnityMagicLeap_MeshingSetLod(levelOfDetail);
            var settings = GetMeshingSettings();

            LuminApi.UnityMagicLeap_MeshingUpdateSettings(settings);
        }
Пример #22
0
        XRInputSubsystem CreateSubsystem()
        {
            SubsystemManager.GetSubsystemDescriptors(s_SubsystemDescriptors);
            if (s_SubsystemDescriptors.Count > 0)
            {
                var descriptor = s_SubsystemDescriptors[0];
                if (s_SubsystemDescriptors.Count > 1)
                {
                    Debug.LogWarningFormat("Multiple {0} found. Using {1}",
                                           typeof(XRInputSubsystem).Name,
                                           descriptor.id);
                }

                return(descriptor.Create());
            }
            else
            {
                return(null);
            }
        }
        private void ConnectCardboardInputSystem()
        {
            List <XRInputSubsystemDescriptor> inputs = new List <XRInputSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(inputs);

            foreach (var d in inputs)
            {
                if (d.id.Equals(inputMatch))
                {
                    XRInputSubsystem inputInst = d.Create();

                    if (inputInst != null)
                    {
                        GCHandle handle = GCHandle.Alloc(inputInst);
                        inputPointer = GCHandle.ToIntPtr(handle);
                    }
                }
            }
        }
        public void RegisterSubsystemTest()
        {
            TestSubsystemDescriptor        descriptor  = new TestSubsystemDescriptor();
            List <TestSubsystemDescriptor> descriptors = new List <TestSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors <TestSubsystemDescriptor>(descriptors);

            Assert.That(0 == descriptors.Count, "TestSubsystemDescriptor already registered.");

            // Populate the descriptor object
            descriptor.holdsThings = true;
            descriptor.id          = "RuntimeTestSubsystem";
            descriptor.subsystemImplementationType = typeof(ConcreteTestSubsystem);

            // Register the descriptor
            Assert.That(true == SubsystemRegistration.CreateDescriptor(descriptor), "Descriptor not added.");
            Assert.That(false == SubsystemRegistration.CreateDescriptor(descriptor), "Descriptor added twice.");

            SubsystemManager.GetSubsystemDescriptors <TestSubsystemDescriptor>(descriptors);
            Assert.That(1 == descriptors.Count, "TestSubsystemDescriptor not registered.");
        }
Пример #25
0
        static TSubsystem CreateSubsystem <TDescriptor, TSubsystem>(List <TDescriptor> descriptors, string id = null)
            where TDescriptor : SubsystemDescriptor <TSubsystem>
            where TSubsystem : Subsystem <TDescriptor>
#endif
        {
            if (descriptors == null)
            {
                throw new ArgumentNullException("descriptors");
            }

            SubsystemManager.GetSubsystemDescriptors <TDescriptor>(descriptors);

            if (descriptors.Count > 0)
            {
                if (!String.IsNullOrEmpty(id))
                {
                    foreach (var descriptor in descriptors)
                    {
                        if (descriptor.id.IndexOf(id, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            return(descriptor.Create());
                        }
                    }
                }
                else
                {
                    var descriptorToUse = descriptors[0];
                    if (descriptors.Count > 1)
                    {
                        Type typeOfD = typeof(TDescriptor);
                        Debug.LogWarningFormat("Found {0} {1}s. Using \"{2}\"",
                                               descriptors.Count, typeOfD.Name, descriptorToUse.id);
                    }

                    return(descriptorToUse.Create());
                }
            }

            return(null);
        }
Пример #26
0
        static TSubsystem CreateStandaloneSubsystem <TDescriptor, TSubsystem>(List <TDescriptor> descriptors, string id = null)
            where TDescriptor : SubsystemDescriptor <TSubsystem>
            where TSubsystem : Subsystem <TDescriptor>
        {
            if (descriptors == null)
            {
                throw new ArgumentNullException("descriptors");
            }

            SubsystemManager.GetSubsystemDescriptors <TDescriptor>(descriptors);

            if (descriptors.Count > 0)
            {
                if (id != null)
                {
                    foreach (var descriptor in descriptors)
                    {
                        if (descriptor.id == id)
                        {
                            return(descriptor.Create());
                        }
                    }
                }
                else
                {
                    var descriptorToUse = descriptors[0];
                    if (descriptors.Count > 1)
                    {
                        Type typeOfD = typeof(TDescriptor);
                        Debug.LogWarningFormat("Found {0} {1}s. Using \"{2}\"",
                                               descriptors.Count, typeOfD.Name, descriptorToUse.id);
                    }

                    return(descriptorToUse.Create());
                }
            }

            return(null);
        }
        private static XRReferencePointSubsystem FindReferencePointManager()
        {
            List <XRReferencePointSubsystemDescriptor> descriptors = new List <XRReferencePointSubsystemDescriptor>();

            SubsystemManager.GetSubsystemDescriptors(descriptors);
            Debug.Log($"Found {descriptors.Count} XRReferencePointSubsystemDescriptors");
            if (descriptors.Count < 1)
            {
                Debug.Log("No XRReferencePointSubsystem descriptors found, failing");
                return(null);
            }
            string descriptorList = "Descriptor List:\n";

            for (int i = 0; i < descriptors.Count; ++i)
            {
                descriptorList += descriptors[i].ToString() + "\n";
            }
            Debug.Log(descriptorList);
            var referencePointManager = descriptors[0].Create();

            Debug.Assert(referencePointManager != null, "Failure creating ReferencePoint manager from descriptor");
            return(referencePointManager);
        }
Пример #28
0
        /// <summary>
        /// Creates a subsystem given a list of descriptors and a specific subsystem id.
        /// </summary>
        ///
        /// <paramref name="TDescriptor">The descriptor type being passed in.</paramref>
        /// <paramref name="TSubsystem">The subsystem type being requested</paramref>
        /// <param name="descriptors">List of TDescriptor instances to use for subsystem matching.</param>
        /// <param name="id">The identifier key of the particualr subsystem implementation being requested.</param>
        protected void CreateSubsystem <TDescriptor, TSubsystem>(List <TDescriptor> descriptors, string id)
            where TDescriptor : IntegratedSubsystemDescriptor <TSubsystem>
            where TSubsystem : IntegratedSubsystem <TDescriptor>
        {
            if (descriptors == null)
            {
                throw new ArgumentNullException("descriptors");
            }

            SubsystemManager.GetSubsystemDescriptors <TDescriptor>(descriptors);

            if (descriptors.Count > 0)
            {
                foreach (var descriptor in descriptors)
                {
                    if (descriptor.id == id)
                    {
                        IntegratedSubsystem s = descriptor.Create();
                        m_SubsystemInstanceMap[typeof(TSubsystem)] = s;
                    }
                }
            }
        }
Пример #29
0
    IEnumerator SwitchToVR()
    {
        SubsystemManager.GetSubsystemDescriptors(displays);
        Debug.Log("Number of display providers found: " + displays.Count);
        foreach (var d in displays)
        {
            Debug.Log("Scanning display id: " + d.id);

            if (d.id.Contains("OpenXR Display"))
            {
                Debug.Log("Creating display " + d.id);
                dispInst = d.Create();
                if (dispInst != null)
                {
                    Debug.Log("Starting display ");
                    dispInst.Start();
                }
            }
        }

        // Wait one frame!
        yield return(null);
    }
        static void CreateMeshSubsystemIfNeeded()
        {
            if (s_MeshSubsystem != null)
            {
                return;
            }

            s_Descriptors.Clear();
            SubsystemManager.GetSubsystemDescriptors <XRMeshSubsystemDescriptor>(s_Descriptors);

            if (s_Descriptors.Count > 0)
            {
                var descriptorToUse = s_Descriptors[0];
                if (s_Descriptors.Count > 1)
                {
                    Type typeOfD = typeof(XRMeshSubsystemDescriptor);
                    Debug.LogWarningFormat("Found {0} {1}s. Using \"{2}\"",
                                           s_Descriptors.Count, typeOfD.Name, descriptorToUse.id);
                }

                s_MeshSubsystem = descriptorToUse.Create();
            }
        }