When using the AssetDatabase.SaveAssetIfDirty
method to save modified assets, the version control system will not automatically check out the modified assets. However, if you use the AssetDatabase.SaveAssets
method, it will automatically check out the modified assets.
[MenuItem("Test/Test Version Control Checkout")]
private static void 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
}