通常我们做动画的时候是这样的
嵌入后是这样的
将代码放到工程里面,对着Control点右键,出现AutoAdd AnimClips in Control,自动把同层所有的AnimClip嵌入到Control里面,同时也会删除这些AnimClips,所以。。。注意备份。
AutoAddAnimClips.cs
代码如下:
using UnityEngine;
using UnityEditor;
public class AutoAddAnimClips : MonoBehaviour
{
[MenuItem("Assets/AutoAdd AnimClips in Controller")]
static public void AutoaddAnimClips()
{
UnityEditor.Animations.AnimatorController anim_controller = null;
AnimationClip[] clips = null;
if (Selection.activeObject.GetType() == typeof(UnityEditor.Animations.AnimatorController))
{
anim_controller = (UnityEditor.Animations.AnimatorController)Selection.activeObject;
clips = anim_controller.animationClips;
if (anim_controller != null && clips.Length > 0)
{
foreach (AnimationClip ac in clips)
{
var acAssetPath = AssetDatabase.GetAssetPath(ac);
// Check if this ac is not in the controller
if (acAssetPath.EndsWith(".anim"))
{
var new_ac = Object.Instantiate(ac) as AnimationClip;
new_ac.name = ac.name;
AssetDatabase.AddObjectToAsset(new_ac, anim_controller);
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(new_ac));
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(ac));
}
}
Debug.Log("<color=orange>Added " + clips.Length.ToString() + " clips to controller: </color><color=yellow>" + anim_controller.name + "</color>");
}
else
{
Debug.Log("<color=red>Nothing done. Select a controller that has anim clips to nest.</color>");
}
}
}
}