- Home /
Question by
Diet-Chugg · Jun 08, 2015 at 07:29 PM ·
editoranimatoranimationclip
In Editor add animation clips to animator controller via code
How would I add animation clips to animator controller via code in the editor? Please note I Do not need to do this at runtime. I'm trying to automate this task so I don't have to do it over 100 times.
Comment
Best Answer
Answer by Diet-Chugg · Jun 08, 2015 at 08:55 PM
Looks like I solved it this round:
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
using System.Collections.Generic;
//MOST IMPORTANTLY USE
using UnityEditor.Animations;
public class Test : MonoBehaviour
{
#if UNITY_EDITOR
public AnimatorController animationController;
public AnimationClip animationClip;
[ContextMenu("Run Test")]
public void Run()
{
Motion motion = (Motion)animationClip as Motion;
animationController.AddMotion(motion);
}
#endif
}
Your answer
Follow this Question
Related Questions
How do I pose a model from an animation in the Unity 4 Editor? 0 Answers
Animation editor Issue and a weird disappearing bug 1 Answer
how to? editor extention like animator with drag n drop elements. 0 Answers
Hiding non-public functions from Animation Event Window? 0 Answers
Animator Override Controller changed at runtime doesn't always play the animations correctly 1 Answer