From da5165657625b4abbc91907ff6c01fa8cfcd6796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 24 Nov 2020 19:57:42 +0100 Subject: [PATCH] Check whether root profile exists (#695) --- Editor/PackageInstaller.cs | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Editor/PackageInstaller.cs b/Editor/PackageInstaller.cs index 32a3bcb47..eb339a5bb 100644 --- a/Editor/PackageInstaller.cs +++ b/Editor/PackageInstaller.cs @@ -139,20 +139,33 @@ private static void AddConfigurations(List profiles) if (platformConfigurationProfile.IsNull()) { continue; } - var rootProfile = MixedRealityToolkit.IsInitialized - ? MixedRealityToolkit.Instance.ActiveProfile - : ScriptableObjectExtensions.GetAllInstances()[0]; - - if (EditorUtility.DisplayDialog("We found a new Platform Configuration", - $"We found the {platformConfigurationProfile.name.ToProperCase()}. Would you like to add this platform configuration to your {rootProfile.name}?", - "Yes, Absolutely!", - "later")) + MixedRealityToolkitRootProfile rootProfile; + if (MixedRealityToolkit.IsInitialized) { - InstallConfiguration(platformConfigurationProfile, rootProfile); + rootProfile = MixedRealityToolkit.Instance.ActiveProfile; } else { - EditorUtility.DisplayDialog("Attention!", "Each data provider will need to be manually registered in each service configuration.", "OK"); + var availableRootProfiles = ScriptableObjectExtensions.GetAllInstances(); + rootProfile = availableRootProfiles.Length > 0 ? availableRootProfiles[0] : null; + } + + // Only if a root profile is available at all it makes sense to display the + // platform configuration import dialog. If the user does not have a root profile yet, + // for whatever reason, there is nothing we can do here. + if (rootProfile.IsNull()) + { + if (EditorUtility.DisplayDialog("We found a new Platform Configuration", + $"We found the {platformConfigurationProfile.name.ToProperCase()}. Would you like to add this platform configuration to your {rootProfile.name}?", + "Yes, Absolutely!", + "later")) + { + InstallConfiguration(platformConfigurationProfile, rootProfile); + } + else + { + EditorUtility.DisplayDialog("Attention!", "Each data provider will need to be manually registered in each service configuration.", "OK"); + } } } }