public static PlayableGraph BuildPlayableGraph(Animator animator, IList <IRigLayer> layers, SyncSceneToStreamLayer syncSceneToStreamLayer) { string graphName = animator.gameObject.transform.name + "_Rigs"; PlayableGraph graph = PlayableGraph.Create(graphName); graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); IEnumerable <PlayableChain> playableChains = BuildPlayables(animator, graph, layers, syncSceneToStreamLayer); foreach (var chain in playableChains) { if (!chain.IsValid()) { continue; } AnimationPlayableOutput output = AnimationPlayableOutput.Create(graph, String.Format("%1-Output", chain.name), animator); output.SetAnimationStreamSource(AnimationStreamSource.PreviousInputs); output.SetSortingOrder(k_AnimationOutputPriority); // Connect last rig playable to output output.SetSourcePlayable(chain.playables[chain.playables.Length - 1]); } return(graph); }
private void Awake() { Graph = new AnimationGraphNode(this); PlayableGraph = PlayableGraph.Create("Animation Graph"); Graph.CreatePlayable(PlayableGraph); PlayableOutput = AnimationPlayableOutput.Create(PlayableGraph, "Animation Output", GetComponent <Animator>()); PlayableOutput.SetSourcePlayable(Graph.Playable); PlayableOutput.SetAnimationStreamSource(AnimationStreamSource.DefaultValues); PlayableGraph.Play(); }