Hi everyone,
I’ve been running into a frustrating issue with Mixamo. When I import models and animations, they come with prefixes like mixamorig6:
in the rig and animation names, which is quite annoying. So, I wrote two AssetPostprocessor
scripts to handle this during import. One script removes the prefixes from the rig, and the other renames animations based on the FBX filename.
using UnityEngine;
using UnityEditor;
public class MixamoRigRenamer : AssetPostprocessor {
private const string prefix = "mixamorig6:";
void OnPostprocessModel(GameObject importedModel) {
RenameRigBones(importedModel.transform);
}
private void RenameRigBones(Transform parent) {
if (parent.name.StartsWith(prefix)) {
parent.name = parent.name.Substring(prefix.Length);
}
foreach (Transform child in parent) {
RenameRigBones(child);
}
}
}
Animation Renamer:
using UnityEngine;
using UnityEditor;
using System.IO;
public class AnimationRenamePostprocessor : AssetPostprocessor {
const string mixamoName = "mixamo.com";
void OnPostprocessAnimation(GameObject gameObject, AnimationClip clip) {
RenameMixamoAnimation(clip);
}
void RenameMixamoAnimation(AnimationClip clip) {
if (clip.name.Equals(mixamoName)) {
string fileName = GetFBXName();
string oldName = clip.name;
clip.name = fileName;
Debug.Log($"Анімаційний кліп '{oldName}' перейменовано на: {fileName}");
} else {
Debug.Log($"Анімаційний кліп '{clip.name}' вже має правильне ім'я.");
}
}
string GetFBXName() {
string assetPath = assetImporter.assetPath;
return Path.GetFileNameWithoutExtension(assetPath);
}
}
The Problem:
Unfortunately, animations dont apply to renamed version of rig bones. And I cant find why.
Has anyone encountered a similar issue, or can anyone spot what might be going wrong with these scripts? Any suggestions would be greatly appreciated!
Thanks in advance!