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; } } }
public static void SetActiveInstance(MixedRealityToolkit toolkitInstance) { // Disable the old instance SetInstanceInactive(activeInstance); // Immediately register the new instance RegisterInstance(toolkitInstance); }
private static void RegisterInstance(MixedRealityToolkit toolkitInstance) { if (MixedRealityToolkit.isApplicationQuitting) { // Don't register instances while application is quitting return; } if (MixedRealityToolkit.activeInstance == null) { // If we don't have an instance, set it here // Set the instance to active MixedRealityToolkit.activeInstance = toolkitInstance; toolkitInstances.Add(toolkitInstance); toolkitInstance.name = ActiveInstanceGameObjectName; toolkitInstance.InitializeInstance(); return; } if (!toolkitInstances.Add(toolkitInstance)) { // If we're already registered, no need to proceed return; } // If we do, then it's not this instance, so deactivate this instance toolkitInstance.name = InactiveInstanceGameObjectName; // Move to the bottom of the heirarchy so it stays out of the way toolkitInstance.transform.SetSiblingIndex(int.MaxValue); }
/// <summary> /// Static function to determine if the MixedRealityToolkit class has been initialized or not. /// </summary> /// <returns></returns> public static bool ConfirmInitialized() { // ReSharper disable once UnusedVariable // Assigning the Instance to access is used Implicitly. MixedRealityToolkit access = Instance; return(IsInitialized); }
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; }