Create a gist now

Instantly share code, notes, and snippets.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Animations;
public class ChangeTargetAnimator : MonoBehaviour
PlayableGraph graph;
AnimationPlayableOutput output;
AnimationClipPlayable clipPlayable;
[SerializeField] Animator[] animators;
[SerializeField] AnimationClip clip;
void Awake()
graph = PlayableGraph.Create ();
void Start()
clipPlayable = AnimationClipPlayable.Create (graph, clip);
output = AnimationPlayableOutput.Create (graph, "animation", null);
output.SetSourcePlayable (clipPlayable);
graph.Play ();
void OnGUI()
foreach( var anim in animators){
if (GUILayout.Button ( {
output.SetTarget (anim);
clipPlayable.SetTime (0);
void OnDestroy()
graph.Destroy ();

This comment has been minimized.

Show comment
Hide comment

tsubaki commented Jul 30, 2017

animation 105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment