/// <summary> /// Restores the default <c>BuildInfo</c> after a build process finishes. /// </summary> /// <param name="report">Build process reported information.</param> public void OnPostprocessBuild(BuildReport report) { GDXConfig config = GDXConfig.Get(); if (config == null || !config.developerBuildInfoEnabled) { return; } BuildInfoProvider.WriteDefaultFile(); }
/// <summary> /// Draw the Build Info section of settings. /// </summary> /// <param name="settings">Serialized <see cref="GDXConfig" /> object to be modified.</param> public static void BuildInfo(SerializedObject settings) { const string sectionID = "GDX.Editor.Build.BuildInfoProvider"; GUI.enabled = true; bool buildInfoEnabled = Layout.CreateSettingsSection( sectionID, false, "BuildInfo Generation", $"{DocumentationUri}api/GDX.Editor.Build.BuildInfoProvider.html", settings.FindProperty("developerBuildInfoEnabled"), Content.BuildInfoEnabled); if (!Layout.GetCachedEditorBoolean(sectionID)) { return; } string buildInfoFile = Path.Combine(Application.dataPath, settings.FindProperty("developerBuildInfoPath").stringValue); if (!File.Exists(buildInfoFile)) { GUILayout.BeginVertical(Styles.InfoBoxStyle); GUILayout.BeginHorizontal(); GUILayout.Label( "There is currently no BuildInfo file in the target location. Would you like some default content written in its place?", Styles.WordWrappedLabelStyle); if (GUILayout.Button("Create Default", Styles.ButtonStyle)) { BuildInfoProvider.WriteDefaultFile(); AssetDatabase.ImportAsset("Assets/" + settings.FindProperty("developerBuildInfoPath").stringValue); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } // Only allow editing based on the feature being enabled GUI.enabled = buildInfoEnabled; EditorGUILayout.PropertyField(settings.FindProperty("developerBuildInfoPath"), Content.BuildInfoPath); EditorGUILayout.PropertyField(settings.FindProperty("developerBuildInfoNamespace"), Content.BuildInfoNamespace); EditorGUILayout.PropertyField(settings.FindProperty("developerBuildInfoAssemblyDefinition"), Content.BuildInfoAssemblyDefinition); GUILayout.Space(10); // Arguments (we're going to make sure they are forced to uppercase). GUILayout.Label("Build Arguments", Styles.SubSectionHeaderTextStyle); SerializedProperty buildNumberProperty = settings.FindProperty("developerBuildInfoBuildNumberArgument"); EditorGUILayout.PropertyField(buildNumberProperty, Content.BuildInfoBuildNumberArgument); if (buildNumberProperty.stringValue.HasLowerCase()) { buildNumberProperty.stringValue = buildNumberProperty.stringValue.ToUpper(); } SerializedProperty buildDescriptionProperty = settings.FindProperty("developerBuildInfoBuildDescriptionArgument"); EditorGUILayout.PropertyField(buildDescriptionProperty, Content.BuildInfoBuildDescriptionArgument); if (buildDescriptionProperty.stringValue.HasLowerCase()) { buildDescriptionProperty.stringValue = buildDescriptionProperty.stringValue.ToUpper(); } SerializedProperty buildChangelistProperty = settings.FindProperty("developerBuildInfoBuildChangelistArgument"); EditorGUILayout.PropertyField(buildChangelistProperty, Content.BuildInfoBuildChangelistArgument); if (buildChangelistProperty.stringValue.HasLowerCase()) { buildChangelistProperty.stringValue = buildChangelistProperty.stringValue.ToUpper(); } SerializedProperty buildTaskProperty = settings.FindProperty("developerBuildInfoBuildTaskArgument"); EditorGUILayout.PropertyField(buildTaskProperty, Content.BuildInfoBuildTaskArgument); if (buildTaskProperty.stringValue.HasLowerCase()) { buildTaskProperty.stringValue = buildTaskProperty.stringValue.ToUpper(); } SerializedProperty buildStreamProperty = settings.FindProperty("developerBuildInfoBuildStreamArgument"); EditorGUILayout.PropertyField(buildStreamProperty, Content.BuildInfoBuildStreamArgument); if (buildStreamProperty.stringValue.HasLowerCase()) { buildStreamProperty.stringValue = buildStreamProperty.stringValue.ToUpper(); } }