I need to rename the bones of many characters because from where I bought the models and animations they rename the bones to prevent people from using the same animations from character to character, why would I have the same animation 30 times when I could have just one animation for all character. So I wanna rename the bones of all characters so I can have the same animations on all characters, could someone help me create a script to do this automatically? I know C# but I have never done anything like this (editor scripting) and bones are to many to rename them manually. What I need to do is add a Prefix to the bones names, I already tested it by doing it manually and it works perfectly.
Thanks in advance.
// Drop this in Assets/Editor, and you will get a new menu item.
// Change the prefix to what you want.
// Backup your project.
// Use menu item to apply changes.
using UnityEngine;
using UnityEditor;
static class PrefixSelectionChildren
{
const string prefix = "PREFIX_"; // Change to whatever you want to prefix with
[MenuItem("Answers/Apply Prefix to Children")]
public static void ApplyPrefix()
{
if (!EditorUtility.DisplayDialog("Child Prefix Warning",
"You are about to rename children of your current selection. Undo is not possible.
Are you sure you want to continue?",
“Yes, I understand the risk”,
“No, I changed my mind”))
return;
GameObject[] gos = Selection.gameObjects;
foreach (GameObject go in gos)
{
var children = go.GetComponentsInChildren(typeof(Transform));
foreach (Transform child in children)
{
// Don't apply to root object.
if (child == go.transform)
continue;
child.name = prefix + child.name;
}
}
}
}