I need to change bones for animations. I can manually open the .anim file in notepad++ and change the bones then save it and it works. I built a class to handle these name changes for me but I cannot figure out how to save it as a .anim for use. Anyone know how to save a string as FileName.anim?
System.IO.File.WriteAllText. I also made a tool to Remap Animation Bindings using a proper GUI. Buying Animancer Pro isn't really worth it for just that tool, but you might be interested in using it as your animation system.
When using StreamWriter I would get an error. Unfortunately with WriteAllText I get no error but even when making no edits I lose all properties at 'root : Scale' and below.
Have you disposed the StreamReader you used to load the file? I'm not sure what would cause you to lose data. My system modifies the actual animation data within Unity rather than parsing it as text.
Maybe that is my problem; I thought I could just modify the text because that is all I did when manually changing animation names in notepad++ and that test being successful. But the act of opening and saving is causing data loss somehow. Code (CSharp): string path = "Assets/Development/Characters/Types/Animations/Stance/Stance_Idle.anim"; StreamReader reader = new StreamReader(path); string data = reader.ReadToEnd(); reader.Close(); File.WriteAllText("Assets/Testing.anim", data); Debug.Log("Complete"); I'll give a look at your source code to try it a different way but be a shame as I spent an entire day working around all the inconsistencys to get the names replaced correctly. Update: I deleted the old Testing.anim and then it fixed the properties issue when creating it. So maybe I just can't trust it to be overwritten properly. I think I just need it to reimport, maybe using AssetDatabase.ForceReserializeAssets, but can't seem to figure out how to target a single asset as documentation sounds like it should be 'AssetDatabase.ForceReserializeAssets(path)' but I'm missing something.
StreamReaders are mostly useful if you want to read things line by line or character by character to avoid needing to allocate memory for the whole thing then chop it up repeatedly. But if you aren't doing that then you might as well use File.ReadAllText instead. Also try calling AssetDatabase.Refresh to see if that lets Unity detect it was modified properly. If not, try AssetDatabase.ImportAsset.