Here are the examples of the csharp api UnityEngine.Timeline.AnimationTrack.CompileTrackPlayable(UnityEngine.Playables.PlayableGraph, UnityEngine.Timeline.AnimationTrack, UnityEngine.GameObject, IntervalTree, UnityEngine.Timeline.AppliedOffsetMode) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
View Source File : AnimationTrack.cs
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski
internal override Playable OnCreateClipPlayableGraph(PlayableGraph graph, GameObject go, IntervalTree<RuntimeElement> tree)
{
if (isSubTrack)
throw new InvalidOperationException("Nested animation tracks should never be asked to create a graph directly");
List<AnimationTrack> flattenTracks = new List<AnimationTrack>();
if (CanCompileClips())
flattenTracks.Add(this);
var genericRoot = GetGenericRootNode(go);
var animatesRootTransformNoMask = AnimatesRootTransform();
var animatesRootTransform = animatesRootTransformNoMask && !IsRootTransformDisabledByMask(go, genericRoot);
foreach (var subTrack in GetChildTracks())
{
var child = subTrack as AnimationTrack;
if (child != null && child.CanCompileClips())
{
var childAnimatesRoot = child.AnimatesRootTransform();
animatesRootTransformNoMask |= child.AnimatesRootTransform();
animatesRootTransform |= (childAnimatesRoot && !child.IsRootTransformDisabledByMask(go, genericRoot));
flattenTracks.Add(child);
}
}
// figure out which mode to apply
AppliedOffsetMode mode = GetOffsetMode(go, animatesRootTransform);
int defaultBlendCount = GetDefaultBlendCount();
var layerMixer = CreateGroupMixer(graph, go, flattenTracks.Count + defaultBlendCount);
for (int c = 0; c < flattenTracks.Count; c++)
{
int blendIndex = c + defaultBlendCount;
// if the child is masking the root transform, compile it as if we are non-root mode
var childMode = mode;
if (mode != AppliedOffsetMode.NoRootTransform && flattenTracks[c].IsRootTransformDisabledByMask(go, genericRoot))
childMode = AppliedOffsetMode.NoRootTransform;
var compiledTrackPlayable = flattenTracks[c].inClipMode ?
CompileTrackPlayable(graph, flattenTracks[c], go, tree, childMode) :
flattenTracks[c].CreateInfiniteTrackPlayable(graph, go, tree, childMode);
graph.Connect(compiledTrackPlayable, 0, layerMixer, blendIndex);
layerMixer.SetInputWeight(blendIndex, flattenTracks[c].inClipMode ? 0 : 1);
if (flattenTracks[c].applyAvatarMask && flattenTracks[c].avatarMask != null)
{
layerMixer.SetLayerMaskFromAvatarMask((uint)blendIndex, flattenTracks[c].avatarMask);
}
}
var requiresMotionXPlayable = RequiresMotionXPlayable(mode, go);
// In the editor, we may require the motion X playable if we are animating the root transform but it is masked out, because the default poses
// need to properly update root motion
requiresMotionXPlayable |= (defaultBlendCount > 0 && RequiresMotionXPlayable(GetOffsetMode(go, animatesRootTransformNoMask), go));
// Attach the default poses
AttachDefaultBlend(graph, layerMixer, requiresMotionXPlayable);
// motionX playable not required in scene offset mode, or root transform mode
Playable mixer = layerMixer;
if (requiresMotionXPlayable)
{
// If we are animating a root transform, add the motionX to delta playable as the root node
var motionXToDelta = AnimationMotionXToDeltaPlayable.Create(graph);
graph.Connect(mixer, 0, motionXToDelta, 0);
motionXToDelta.SetInputWeight(0, 1.0f);
motionXToDelta.SetAbsoluteMotion(UsesAbsoluteMotion(mode));
mixer = (Playable)motionXToDelta;
}
#if UNITY_EDITOR
if (!Application.isPlaying)
{
var animator = GetBinding(go != null ? go.GetComponent<PlayableDirector>() : null);
if (animator != null)
{
GameObject targetGO = animator.gameObject;
IAnimationWindowPreview[] previewComponents = targetGO.GetComponents<IAnimationWindowPreview>();
m_HasPreviewComponents = previewComponents.Length > 0;
if (m_HasPreviewComponents)
{
foreach (var component in previewComponents)
{
mixer = component.BuildPreviewGraph(graph, mixer);
}
}
}
}
#endif
return mixer;
}