private static void UnregisterInstance(MixedRealityToolkit toolkitInstance) { toolkitInstances.Remove(toolkitInstance); if (MixedRealityToolkit.activeInstance == toolkitInstance) { // If this is the active instance, we need to break it down toolkitInstance.DestroyAllServices(); toolkitInstance.ClearCoreSystemCache(); // If this was the active instance, un-register the active instance MixedRealityToolkit.activeInstance = null; if (MixedRealityToolkit.isApplicationQuitting) { // Don't search for additional instances if we're quitting return; } foreach (MixedRealityToolkit instance in toolkitInstances) { if (instance == null) { // This may have been a mass-deletion - be wary of soon-to-be-unregistered instances continue; } // Select the first available instance and register it immediately RegisterInstance(instance); break; } } }
private static void SetInstanceInactive(MixedRealityToolkit toolkitInstance) { if (toolkitInstance == null) { // Don't do anything. return; } if (toolkitInstance == activeInstance) { // If this is the active instance, we need to break it down toolkitInstance.DestroyAllServices(); toolkitInstance.ClearCoreSystemCache(); // If this was the active instance, un-register the active instance MixedRealityToolkit.activeInstance = null; } toolkitInstance.name = InactiveInstanceGameObjectName; }