Hello ! I’m trying to replace ‘@’ with ‘/’ in the AnimationClip’s internal name, and it works great on asset creation/move :
Problem is it doesn’t work when I’m just renaming assets. Here is the code :
using UnityEngine;
using UnityEditor;
using System.IO;
class AnimationPostprocessor : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
FindAndTrySetInternalClipName(importedAssets);
FindAndTrySetInternalClipName(movedAssets);
}
private static void FindAndTrySetInternalClipName(string[] assets)
{
for (int i = 0; i != assets.Length; i++)
{
string path = assets[i];
if (!path.Contains("@") || !string.Equals(Path.GetExtension(path), ".anim")) continue;
AnimationClip clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(path);
clip.name = clip.name.Replace('@', '/');
}
}
}
I tried a bunch of solutions (SerializedObject, AssetModificationProcessor, ForceReserializeAssets, GetPostprocessOrder) but none of them work. Any idea ?