Skip to content

Instantly share code, notes, and snippets.

@mitay-walle
Last active September 27, 2024 08:36
Show Gist options
  • Save mitay-walle/c6ff675d7ff4f66db244c84ae60c62fc to your computer and use it in GitHub Desktop.
Save mitay-walle/c6ff675d7ff4f66db244c84ae60c62fc to your computer and use it in GitHub Desktop.
Unity3d Menu Item to rename "Mixamo" animations to same as file-name
[MenuItem("Assets/Rename Animations")]
private static void RenameAnimations()
{
Selection.objects.Where(EditorUtility.IsPersistent)
.Select(AssetDatabase.GetAssetPath)
.ForEach(path =>
{
string fileName = Path.GetFileNameWithoutExtension(path);
ModelImporter importer = (ModelImporter)AssetImporter.GetAtPath(path);
RenameAndImport(importer, fileName);
});
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
private static void RenameAndImport(ModelImporter modelImporter, string name)
{
ModelImporterClipAnimation[] clipAnimations = modelImporter.defaultClipAnimations;
for (int i = 0; i < clipAnimations.Length; i++)
{
clipAnimations[i].name = name;
}
modelImporter.clipAnimations = clipAnimations;
modelImporter.SaveAndReimport();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment