public void SwapClipTo(ref Playable ownPlayable, AnimationClip animationClip) { clip = animationClip; var asClipPlayable = (AnimationClipPlayable)ownPlayable; PlayableUtilities.ReplaceClipInPlace(ref asClipPlayable, GetClipToUseFor(animationClip)); ownPlayable = asClipPlayable; }
public override void OnClipSwapsChanged(ref Playable ownPlayable) { var asClipPlayable = (AnimationClipPlayable)ownPlayable; var clipToUse = GetClipToUseFor(clip); if (asClipPlayable.GetAnimationClip() != clipToUse) { PlayableUtilities.ReplaceClipInPlace(ref asClipPlayable, clipToUse); ownPlayable = asClipPlayable; } }
public override void OnClipSwapsChanged(ref Playable ownPlayable) { var asClipPlayable = (AnimationClipPlayable)ownPlayable; var shouldBePlaying = ClipsToUse[indexOfPlayedClip]; var isPlaying = asClipPlayable.GetAnimationClip(); if (shouldBePlaying != isPlaying) { PlayableUtilities.ReplaceClipInPlace(ref asClipPlayable, shouldBePlaying); ownPlayable = asClipPlayable; } }
public override void OnClipSwapsChanged(ref Playable ownPlayable) { var asMixer = (AnimationMixerPlayable)ownPlayable; var inputCount = asMixer.GetInputCount(); for (int i = 0; i < inputCount; i++) { var clipPlayable = (AnimationClipPlayable)asMixer.GetInput(i); var shouldPlay = GetClipToUseFor(blendTree[i].clip); var isPlaying = clipPlayable.GetAnimationClip(); if (isPlaying != shouldPlay) { PlayableUtilities.ReplaceClipInPlace(ref clipPlayable, shouldPlay); } } }
public override void OnWillStartPlaying(ref Playable ownPlayable) { //this happens if we're looping, and were already partially playing when the state were started. In that case, don't snap to a different random choice. if (ownPlayable.GetTime() > 0f) { return; } var wantedClip = clips.GetRandomIdx(); if (wantedClip == playedClip) { return; } playedClip = wantedClip; var asClipPlayable = (AnimationClipPlayable)ownPlayable; PlayableUtilities.ReplaceClipInPlace(ref asClipPlayable, ClipsToUse[wantedClip]); ownPlayable = asClipPlayable; }
private void SwapPlayedClipTo(ref AnimationClipPlayable runtimePlayable, AnimationClip clipToUse, double timeToPlayClipAt) { PlayableUtilities.ReplaceClipInPlace(ref runtimePlayable, clipToUse); runtimePlayable.SetTime(timeToPlayClipAt); runtimePlayable.GetGraph().Evaluate(); // Otherwise the clip snaps the character to the default pose for a frame. }