What are the MixedRealityServiceRegistry and IMixedRealityServiceRegistrar?
The Mixed Reality Toolkit has two very similarly named components that perform related tasks: MixedRealityServiceRegistry and IMixedRealityServiceRegistrar.
MixedRealityServiceRegistry
The Mixed
Note
The MixedRealityServiceRegistry contains instances of objects that
implement IMixed
Objects implementing the IMixed
The MixedRealityServiceRegistry is implemented as a static C# class and is the recommended pattern to use to acquire service instances in application code.
The following snippet demonstrates acquiring an IMixedRealityInputSystem instance.
IMixedRealityInputSystem inputSystem = null;
if (!MixedRealityServiceRegistry.TryGetService<IMixedRealityInputSystem>(out inputSystem))
{
// Failed to acquire the input system. It may not have been registered
}
IMixedRealityServiceRegistrar
The IMixed
Other registrars can be found in the MRTK/SDK/Experimental/Features folder. These components can be used to add single service (ex: Spatial Awareness) support to an application. These single service managers are listed below.
- Boundary
System Manager - Camera
System Manager - Diagnostics
System Manager - Input
System Manager - Spatial
Awareness System Manager - Teleport
System Manager
Each of the above components, with the exception of the InputSystemManager, are responsible for managing the registration and status of a single service type. The InputSystem requires some additional support services (ex: FocusProvider) that are also managed by the InputSystemManager.
In general, the methods defined by IMixedRealityServiceRegistrar are called internally by service management components or called by services that require additional service components to function correctly. Application code should, generally, not call these methods as doing so may cause the application to behave unpredictably (ex: a cached service instance may become invalid).