- Home /
How do I nest existing AnimationClip under AnimationControler?
I'm trying to achieve similar thing as people in this thread but with existing AnimationClip. So, I have 1 AnimationController and a couple of AnimationClips and I wish to write custom inspector that will allow me to move those clips under controller. End result should be similar to default button's controller.
Script I have so far:
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
clip = EditorGUILayout.ObjectField("Animation Clip", clip, typeof(AnimationClip), false) as AnimationClip;
if (clip != null)
{
if (GUILayout.Button("Nest under controller"))
{
AssetDatabase.AddObjectToAsset(clip, controller);
clip = null;
}
}
else
GUILayout.Label("Assign animation clip you want to nest under controller!");
}
But Unity complains asset already exists... I tried deleting it first but then it's null and I can't add it to controller. Any ideas?
Your answer
Follow this Question
Related Questions
Animation Rig Import Problem 1 Answer
is it possible to animate a mesh that was imported with another model? 1 Answer
Back to "default transform" after animation interrupts 1 Answer
Not all animations are replaced when using an Animator Override Controller 0 Answers
Play simple animations on demand 1 Answer