Unity Issue Tracker - AssetDatabase.SaveAssetIfDirty does not automatically check out assets
Fixed
UUM-66169
AssetDatabase.SaveAssetIfDirty does not automatically check out assets
Unity: Asset - Database
Fixed
6.0.X
2022.3.X
Won't Fix
6.2.X
6.1.X
2023.3.X
2023.2.X
2023.1.X
2022.2.X
2022.1.X
this port was created wrongly, the fix landed in 6000.0.0b16 - so it is included in in 6.1 and 6.2
Superseded by version 6000.x
Cancelling this 2023.2 tech release issue since the support for this release has come to end of life. Cancelling this 2023.2 port case does not affect any LTS or Unity 6 Beta/Preview that remain open.
2023.1 is finished
2022.2 is finished
2022.1 is finished
Steps to reproduce:
1. Set up a project under VCS (e.g. P4) with at least one asset in it.
2. Make a script that calls EditorUtility.SetDirty() on the asset
3. Call AssetDatabase.SaveAssetIfDirty() on the asset
Actual results:
Asset is not checked out in source control
Expected results:
Asset is checked out in source control
Reproducible with versions:
2020.3 onwards (landed in 2022.1, and backported)
Not reproducible with versions:
Can’t test with versions:
Tested on (OS):
macOS, Windows
Notes:
Can use something like this to test :
[MenuItem("Test/Test Version Control Checkout")]
privatestaticvoid TestVersionControlCheckout()
{
var asset = LoadScriptableObject(); // load an asset
asset.stringField += "_NewContent"; // make some changes
EditorUtility.SetDirty(asset);
// AssetDatabase.SaveAssets(); // ok, will checkout the asset
AssetDatabase.SaveAssetIfDirty(asset); // not ok, will not checkout the asset
}