I am trying to change the name of the sub-sprites of a sprite sheet. I have searched and tried everything I can think of and cannot get it to work, which makes me think it can't be done at this point in time.
Let's say I have a sprite sheet that has already been split up into individual sprites inside of Unity.
I am attempting to change the sub-sprite names programmatically.
I tried using
AssetDatabase.RenameAsset (...)
on the sprite sheet asset, which only changes the sprite sheet name and not sub-sprites.
I then thought to obtain a sub-sprite and attempt to change its name using the below code.
if (AssetDatabase.IsSubAsset (subSprite))
{
AssetDatabase.RenameAsset (AssetDatabase.GetAssetPath (subSprite), "newSprite" + i.ToString ());
}
However, this too only changes the sprite sheet name.
I'm not sure where else I can take this to achieve my desired outcome, apart from programmatically copying the original sprite sheet and using that to create a copy. But even then, I still am unable to alter the sub-sprite names.
I also tried changing subSprite.name, but this just changes the internal name and not the asset name.
Any ideas?
AssetDatabase.GetAssetPath
call gives you the path you would expect? If not then my guess would be that your subsprites aren't really files on disk but rather just metadata about the section of the parent sprite. \$\endgroup\$.meta
files. Last I checked they didn't have anything super important in them but it would be worth a shot. Maybe there are some other files that Unity creates that deal with the sprite sheet what you could edit. I don't think that they actually splice the image into different images though; pretty sure it's all just coordinate data somewhere. That somewhere is probably also where the names are. \$\endgroup\$