Example #1
0
 private void OnGUI()
 {
     EditorGUILayout.LabelField("Required changes", EditorStyles.boldLabel);
     AddControls(PlayInstantSettingPolicy.GetRequiredPolicies());
     GUILayout.Space(10);
     EditorGUILayout.LabelField("Recommended changes", EditorStyles.boldLabel);
     AddControls(PlayInstantSettingPolicy.GetRecommendedPolicies());
 }
        public virtual bool Initialize(BuildToolLogger buildToolLogger)
        {
            IsInstantBuild = PlayInstantBuildSettings.IsInstantBuildType();
            if (!IsInstantBuild)
            {
                if (!_isInstantRequired)
                {
                    // Check passed: this is a persistent app build invoked by a builder that supports persistent apps.
                    return(true);
                }

                // This builder only works for instant apps, however the build isn't currently set to instant.
                Debug.LogError("Build halted since selected build type is \"Installed\"");
                var instantRequiredMessage = string.Format(
                    "The currently selected Android build type is \"Installed\".\n\n" +
                    "Click \"{0}\" to open the \"{1}\" window where the build type can be changed to \"Instant\".",
                    WindowUtils.OkButtonText, BuildSettingsWindow.WindowTitle);
                if (buildToolLogger.DisplayActionableErrorDialog(instantRequiredMessage))
                {
                    BuildSettingsWindow.ShowWindow();
                }

                return(false);
            }

            // This is an instant app build. Verify that instant-specific required policies are enabled.
            var failedPolicies = PlayInstantSettingPolicy.GetRequiredPolicies()
                                 .Where(policy => !policy.IsCorrectState())
                                 .Select(policy => policy.Name).ToArray();

            if (failedPolicies.Length == 0)
            {
                return(true);
            }

            Debug.LogErrorFormat(
                "Build halted due to incompatible settings: {0}", string.Join(", ", failedPolicies));
            var failedPoliciesMessage = string.Format(
                "{0}\n\nClick \"{1}\" to open the settings window and make required changes.",
                string.Join("\n\n", failedPolicies),
                WindowUtils.OkButtonText);

            if (buildToolLogger.DisplayActionableErrorDialog(failedPoliciesMessage))
            {
                PlayerSettingsWindow.ShowWindow();
            }

            return(false);
        }