Skip to content

BuildSettings ScriptableObject is not marked dirty after build, changes not saved. #157

@goto01

Description

@goto01

Description

Hi! First of all thanks a lot for this tool. It really helped me set up my build pipeline and publish my builds to Steam.

However, I ran into a small issue. After a successful build, if the build number was changed inside the BuildSettings ScriptableObject, Unity doesn't detect it as a modified asset. So the updated build number is not saved automatically.

Basically, the build number in the ScriptableObject updates, but the asset isn't marked as dirty, so it never gets written to disk unless I change it manually (for example, add a new build action). Additionally, not all asset changes are automatically detected and saved by Unity.

Current workaround

Right now, I fix this by forcing Unity to mark the ScriptableObject as dirty after the build. This way it saves the new value to disk, and I can see the change in Git right away.

using SuperUnityBuild.BuildTool;
using UnityEditor;
using UnityEngine;

namespace Game
{
    public class SaveSuperUnityBuildConfiguration : BuildAction, IPostBuildAction
    {
        [SerializeField] 
        private BuildSettings _buildSettings;

        public override void Execute()
        {
            EditorUtility.SetDirty(_buildSettings);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
    }
}

This works, but the core problem still exists, anytime something updates through the custom editor, the ScriptableObject should be marked dirty automatically, otherwise Unity won't save it.

Problem in CI/CD

This becomes a real issue in CI\CD, for example, I build version 3.0.0.33, build number increments, but the change is never committed and pushed. So the next build also becomes3.0.0.33, which breaks versioning.

So it would be great if the tool automatically marks the config asset as dirty after updating values.

Hope this makes sense. Let me know if you need more info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions