/// <summary>
        /// Remove managers from the Mixed Reality Manager active manager registry for a given type and name
        /// Name is only supported for Mixed Reality runtime components
        /// </summary>
        /// <param name="type">The interface type for the system to be removed.  E.G. InputSystem, BoundarySystem</param>
        /// <param name="managerName">The name of the manager to be removed. (Only for runtime components) </param>
        public void RemoveManager(Type type, string managerName)
        {
            if (ActiveProfile == null)
            {
                throw new ArgumentNullException($"Unable to remove {nameof(type)} Manager as the Mixed Reality Manager has no Active Profile");
            }

            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (string.IsNullOrEmpty(managerName))
            {
                throw new ArgumentNullException(nameof(managerName));
            }

            if (IsCoreManagerType(type))
            {
                ActiveProfile.ActiveManagers.Remove(type);
            }
            else
            {
                MixedRealityComponents.RemoveAll(tuple => tuple.Item1.Name == type.Name && tuple.Item2.Name == managerName);
            }
        }
示例#2
0
        /// <summary>
        /// Remove services from the Mixed Reality Toolkit active service registry for a given type and name
        /// Name is only supported for Mixed Reality runtime components
        /// </summary>
        /// <param name="type">The interface type for the system to be removed.  E.G. InputSystem, BoundarySystem</param>
        /// <param name="serviceName">The name of the service to be removed. (Only for runtime components) </param>
        public void UnregisterService(Type type, string serviceName)
        {
            if (ActiveProfile == null)
            {
                Debug.LogError($"Unable to remove {serviceName} Manager as the Mixed Reality Manager has no Active Profile.");
                return;
            }

            if (type == null)
            {
                Debug.LogError("Unable to remove null manager type.");
                return;
            }

            if (string.IsNullOrEmpty(serviceName))
            {
                Debug.LogError("Unable to remove manager by name without the name being specified.");
                return;
            }

            if (IsCoreSystem(type))
            {
                ActiveProfile.ActiveServices.Remove(type);
            }
            else
            {
                IMixedRealityService service;

                if (GetService(type, serviceName, out service))
                {
                    MixedRealityComponents.Remove(new Tuple <Type, IMixedRealityExtensionService>(type, (IMixedRealityExtensionService)service));
                }
            }
        }
示例#3
0
        /// <summary>
        /// Remove all services from the Mixed Reality Toolkit active service registry for a given type
        /// </summary>
        /// <param name="type">The interface type for the system to be removed.  E.G. InputSystem, BoundarySystem</param>
        public void UnregisterService(Type type)
        {
            if (ActiveProfile == null)
            {
                Debug.LogError($"Unable to remove {nameof(type)} Manager as the Mixed Reality Manager has no Active Profile.");
                return;
            }

            if (type == null)
            {
                Debug.LogError("Unable to remove null manager type.");
                return;
            }

            if (IsCoreSystem(type))
            {
                ActiveProfile.ActiveServices.Remove(type);
            }
            else
            {
                IMixedRealityService service;
                GetService(type, out service);
                if (service != null)
                {
                    MixedRealityComponents.Remove(new Tuple <Type, IMixedRealityExtensionService>(type, (IMixedRealityExtensionService)service));
                }
            }
        }
示例#4
0
        /// <summary>
        /// Add a new service to the Mixed Reality Toolkit active service registry.
        /// </summary>
        /// <param name="type">The interface type for the system to be managed.  E.G. InputSystem, BoundarySystem</param>
        /// <param name="service">The Instance of the service class to register</param>
        public bool RegisterService(Type type, IMixedRealityService service)
        {
            if (ActiveProfile == null)
            {
                Debug.LogError($"Unable to add a new {type.Name} Service as the Mixed Reality Toolkit has to Active Profile");
                return(false);
            }

            if (type == null)
            {
                Debug.LogWarning("Unable to add a manager of type null.");
                return(false);
            }

            if (service == null)
            {
                Debug.LogWarning("Unable to add a manager with a null instance.");
                return(false);
            }

            if (IsCoreSystem(type))
            {
                IMixedRealityService preExistingService;

                ActiveProfile.ActiveServices.TryGetValue(type, out preExistingService);

                if (preExistingService == null)
                {
                    ActiveProfile.ActiveServices.Add(type, service);
                    return(true);
                }

                Debug.LogError($"There's already a {type.Name} registered.");
                return(false);
            }

            if (!typeof(IMixedRealityExtensionService).IsAssignableFrom(type))
            {
                Debug.LogError($"Unable to register {type}. Concrete type does not implement the IMixedRealityExtensionService implementation.");
                return(false);
            }

            MixedRealityComponents.Add(new Tuple <Type, IMixedRealityExtensionService>(type, (IMixedRealityExtensionService)service));
            if (!isInitializing)
            {
                service.Initialize();
            }
            mixedRealityComponentsCount = MixedRealityComponents.Count;
            return(true);
        }
        /// <summary>
        /// Add a new manager to the Mixed Reality Manager active Manager registry.
        /// </summary>
        /// <param name="type">The interface type for the system to be managed.  E.G. InputSystem, BoundarySystem</param>
        /// <param name="manager">The Instance of the manager class to register</param>
        public void AddManager(Type type, IMixedRealityManager manager)
        {
            if (ActiveProfile == null)
            {
                Debug.LogError($"Unable to add a new {type.Name} Manager as the Mixed Reality manager has to Active Profile");
            }

            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            if (IsCoreManagerType(type))
            {
                IMixedRealityManager preexistingManager;
                if (IsCoreManagerType(type))
                {
                    ActiveProfile.ActiveManagers.TryGetValue(type, out preexistingManager);
                }
                else
                {
                    GetComponentByType(type, out preexistingManager);
                }

                if (preexistingManager == null)
                {
                    ActiveProfile.ActiveManagers.Add(type, manager);
                }
                else
                {
                    Debug.LogError($"There's already a {type.Name} registered.");
                }
            }
            else
            {
                MixedRealityComponents.Add(new Tuple <Type, IMixedRealityManager>(type, manager));
                if (!isMixedRealityManagerInitializing)
                {
                    manager.Initialize();
                }
                mixedRealityComponentsCount = MixedRealityComponents.Count;
            }
        }
        private void DestroyAllManagers()
        {
            //If the Mixed Reality Manager is not configured, stop.
            if (activeProfile == null)
            {
                return;
            }

            // Destroy all active managers in the registry
            foreach (var manager in activeProfile.ActiveManagers)
            {
                manager.Value.Destroy();
            }

            activeProfile.ActiveManagers.Clear();

            // Destroy all registered runtime components
            foreach (var manager in MixedRealityComponents)
            {
                manager.Item2.Destroy();
            }

            MixedRealityComponents.Clear();
        }
示例#7
0
        private void DestroyAllServices()
        {
            //If the Mixed Reality Toolkit is not configured, stop.
            if (activeProfile == null)
            {
                return;
            }

            // Destroy all active services in the registry
            foreach (var service in activeProfile.ActiveServices)
            {
                service.Value.Destroy();
            }

            activeProfile.ActiveServices.Clear();

            // Destroy all registered runtime components
            foreach (var component in MixedRealityComponents)
            {
                component.Item2.Destroy();
            }

            MixedRealityComponents.Clear();
        }