Is it possible to add more than one clip to the track via Script?
Hi there, I want to create a track and add more than one animation via script like image below.
Is it possible?
I use a working code below from @rhaak17, ading a track and an animation, not playing well.
Can anyone help us? public class olustur : MonoBehaviour
{
public AnimationClip clip; //this is just one animation
public AnimationClip[] clips; //there are 6 animation here
void Start()
{
PlayableDirector scenePlayableDirectorComponent = GetComponent<PlayableDirector>();
//get timelineAsset from playableDirector
TimelineAsset timelineAsset = (TimelineAsset)scenePlayableDirectorComponent.playableAsset;
//create new animationTrack on timeline
var newTrack = timelineAsset.CreateTrack<AnimationTrack>(null, "Animation Track " + GetComponent<Animator>());
//bind object to which the animation shell be assigned to the created animationTrack
scenePlayableDirectorComponent.SetGenericBinding(newTrack, this);
//create a timelineClip for the animationClip on the AnimationTrack
var timelineClip = newTrack.CreateClip(clip);
//instantiate playable for animationClip
AnimationClipPlayable playable = AnimationClipPlayable.Create(scenePlayableDirectorComponent.playableGraph, clip);
//Create output for animator of object to assign animationClip to
AnimationPlayableOutput output = AnimationPlayableOutput.Create(scenePlayableDirectorComponent.playableGraph, this.name + " output", GetComponent<Animator>());
//setSourcePlayable for output
output.SetSourcePlayable<AnimationPlayableOutput, AnimationClipPlayable>(playable);
}
001514.jpg
(65.0 kB)
Comment
Your answer
Follow this Question
Related Questions
Problem while editing animation clips on timeline 1 Answer
Recording animation into the timeline (and playing it back) at runtime 1 Answer
Timeline and morphing done in 3D max and other programs, Help! 0 Answers
Why can't a Timeline key frame contain zero Position values? 2 Answers
Can't animate Text Color (Timeline) 0 Answers