Hi all! I'm trying to cobble together an animation system built on Playables, and I've hit a snag on trying to preview blend trees and transitions. For a single clip, it's relatively easy to show a preview in the editor; simply use the AnimationMode API. That doesn't allow me to preview ie. a blend between an idle and walk animation, though. I've tried to make a Playable graph as I do runtime, and manually update it's time, but that doesn't seem to have any effect in the editor, the model is stuck in it's bind pose. I know this is possible internally, as the Animator shows this kind of previews. I just need to figure out if it can be done with the Playable system.
Hi baste, Can you show us what you did try exactly? I don't know if you did try this but I would use the animator component to actually update the scene, so basically you manually update the time of your playable and then call Animator.Update(0) to write the result on the scene transform.
Hi! My bad, actually. I went back to try calling Animator.Update, and realized that I hadn't set the weight on any of my AnimationMixerPlayable. Whoops! Calling Animator.Update is not necessary, I just need to call graph.Evaluate on a graph that's got the Animator as a target. Here's the working code: Spoiler: Code Code (csharp): using UnityEngine; using UnityEngine.Animations; using UnityEngine.Playables; #if UNITY_EDITOR using UnityEditor; #endif public class RuntimePlayable : MonoBehaviour { public AnimationClip clipA; public AnimationClip clipB; private PlayableGraph graph; private BlenderPlayableBehaviour blendBehaviour; public void StartPlaying () { graph = PlayableGraph.Create(); //ensureComponent adds the component if it can't be found var animOutput = AnimationPlayableOutput.Create(graph, "AnimationOutput", gameObject.EnsureComponent<Animator>()); var mixerPlayable = AnimationMixerPlayable.Create(graph, 2, true); var clipPlayableA = AnimationClipPlayable.Create(graph, clipA); var clipPlayableB = AnimationClipPlayable.Create(graph, clipB); graph.Connect(clipPlayableA, 0, mixerPlayable, 0); graph.Connect(clipPlayableB, 0, mixerPlayable, 1); mixerPlayable.SetInputWeight(0, .5f); mixerPlayable.SetInputWeight(1, .5f); animOutput.SetSourcePlayable(mixerPlayable); graph.Play(); } public void Tick() { graph.Evaluate(.1f); } private void OnDestroy() { graph.Destroy(); } } #if UNITY_EDITOR [CustomEditor(typeof(RuntimePlayable))] public class RuntimePlayableEditor : Editor { private RuntimePlayable script; void OnEnable() { script = (RuntimePlayable) target; } public override void OnInspectorGUI() { base.OnInspectorGUI(); if (GUILayout.Button("Start")) { script.StartPlaying(); } if (GUILayout.Button("Tick")) { script.Tick(); } } } #endif By the way, the AnimationMode API's example states: That's no longer the case, as I found out when testing it. I guess you fixed that bug! So that part can be removed from the docs.