I'm writing a script that assigns SpineAtlasAsset objects to SkeletonDataAsset objects, using code like this:
var skelDataRef = AssetDatabase.LoadAssetAtPath<SkeletonDataAsset>(skelDataPath);
var atlasRef = AssetDatabase.LoadAssetAtPath<SpineAtlasAsset>(atlasPath);
skelDataRef.atlasAssets[0] = atlasRef;
Originally, this code would work, but only until Unity was relaunched, at which point the change would be seen to have not persisted.
So, I added this:
EditorUtility.SetDirty(skelDataRef);
AssetDatabase.SaveAssets();
And, strangely, this works
but only AFTER Unity has been relaunched! For some reason it now does not reflect my changes until I've totally quit the Editor (not even if I close and re-open the current scene).
Is there anything obvious that I'm missing here? I even tried changing
skelDataRef.atlasAssets[0] = atlasRef;
to
skelDataRef.atlasAssets = new SpineAtlasAsset[]{atlasRef};
in case there was a setter involved, but it doesn't seem to have changed anything... What's the proper way to give a Skeleton asset a new Atlas in code, in a permanent way?