public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) { ScriptPlayable <Spine3DAnimatorChannelTrackMixer> playable = TimelineUtils.CreateTrackMixer <Spine3DAnimatorChannelTrackMixer>(this, graph, go, inputCount); Spine3DAnimatorTrack parentTrack = this.parent as Spine3DAnimatorTrack; if (parentTrack != null) { Spine3DAnimatorTrackMixer parentMixer = TimelineUtils.GetTrackMixer <Spine3DAnimatorTrackMixer>(graph, parentTrack); if (parentMixer != null) { Spine3DAnimatorChannelTrackMixer mixer = playable.GetBehaviour(); mixer.Init(parentMixer); IEnumerable <TimelineClip> clips = GetClips(); foreach (TimelineClip clip in clips) { Spine3DAnimationClipAsset animationClip = clip.asset as Spine3DAnimationClipAsset; if (animationClip != null) { clip.displayName = animationClip._animationId; animationClip.SetParentTrack(parentTrack); } } } } return(playable); }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <Spine3DAnimatorPlayableBehaviour> .Create(graph, new Spine3DAnimatorPlayableBehaviour()); Spine3DAnimatorPlayableBehaviour clone = playable.GetBehaviour(); Spine3DAnimatorTrackMixer trackMixer = TimelineUtils.GetTrackMixer <Spine3DAnimatorTrackMixer>(graph, _parentAnimatorTrack); clone._clipAsset = this; if (trackMixer != null && trackMixer.GetTrackBinding() != null && !string.IsNullOrEmpty(_animationId)) { clone._animationId = _animationId; clone._animationDuration = trackMixer.GetTrackBinding().GetAnimationLength(_animationId); clone._animationSpeed = _animationSpeed; clone._proxyAnimationOrientations = (eSpine3DOrientation)int.MaxValue; } return(playable); }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { ScriptPlayable <Spine3DAnimatorPlayableBehaviour> playable = ScriptPlayable <Spine3DAnimatorPlayableBehaviour> .Create(graph, new Spine3DAnimatorPlayableBehaviour()); Spine3DAnimatorPlayableBehaviour clone = playable.GetBehaviour(); Spine3DAnimatorTrackMixer trackMixer = TimelineUtils.GetTrackMixer <Spine3DAnimatorTrackMixer>(graph, _parentAnimatorTrack); clone._clipAsset = this; if (_animationSource != null && !string.IsNullOrEmpty(_animationId)) { SkeletonData skeletonData = _animationSource.GetSkeletonData(false); Animation animation = skeletonData.FindAnimation(_animationId); clone._animationDuration = animation != null ? animation.Duration : (float)PlayableBinding.DefaultDuration; clone._animationSpeed = _animationSpeed; clone._proxyAnimation = animation; clone._proxyAnimationOrientations = _validOrientations; } return(playable); }
protected override void PrepareChannelFrame(Playable playable) { int numInputs = playable.GetInputCount(); Spine3DAnimatorTrackMixer.ChannelAnimationData primaryAnimation = new Spine3DAnimatorTrackMixer.ChannelAnimationData(); List <Spine3DAnimatorTrackMixer.ChannelAnimationData> backgroundAnimations = new List <Spine3DAnimatorTrackMixer.ChannelAnimationData>(); for (int i = 0; i < numInputs; i++) { ScriptPlayable <Spine3DAnimatorPlayableBehaviour> scriptPlayable = (ScriptPlayable <Spine3DAnimatorPlayableBehaviour>)playable.GetInput(i); Spine3DAnimatorPlayableBehaviour inputBehaviour = scriptPlayable.GetBehaviour(); if (inputBehaviour != null && (!string.IsNullOrEmpty(inputBehaviour._animationId) || inputBehaviour._proxyAnimation != null)) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.0f) { TimelineClip clip = TimelineUtils.GetClip(_trackAsset, inputBehaviour._clipAsset); if (clip != null) { double clipStart = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start; double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration; if (_director.time >= clipStart && _director.time <= clipStart + clipDuration) { bool isPrimaryClip = IsPrimaryClip(clip); //Work out track time float animationDuration = inputBehaviour._animationDuration; float trackTime = GetExtrapolatedTrackTime(clip, _director.time, animationDuration); if (isPrimaryClip) { primaryAnimation._animationId = inputBehaviour._animationId; primaryAnimation._animationTime = trackTime; primaryAnimation._animationWeight = inputWeight; primaryAnimation._animationSpeed = inputBehaviour._animationSpeed; primaryAnimation._proxyAnimation = inputBehaviour._proxyAnimation; primaryAnimation._proxyAnimationOrientations = inputBehaviour._proxyAnimationOrientations; } else { Spine3DAnimatorTrackMixer.ChannelAnimationData backroundAnimation = new Spine3DAnimatorTrackMixer.ChannelAnimationData { _animationId = inputBehaviour._animationId, _animationTime = trackTime, _animationWeight = 1.0f, _animationSpeed = inputBehaviour._animationSpeed, _proxyAnimation = inputBehaviour._proxyAnimation, _proxyAnimationOrientations = inputBehaviour._proxyAnimationOrientations, }; backgroundAnimations.Add(backroundAnimation); } } } } } } Spine3DAnimatorTrackMixer parentMixer = (Spine3DAnimatorTrackMixer)_parentMixer; Spine3DAnimatorChannelTrack track = (Spine3DAnimatorChannelTrack)_trackAsset; parentMixer.SetChannelData(track._animationChannel, primaryAnimation, backgroundAnimations.ToArray()); }