[unity] Update Timeline code.

This commit is contained in:
pharan 2018-07-13 23:45:20 +08:00
parent e4eff73497
commit 13cb394353
3 changed files with 17 additions and 11 deletions

View File

@ -40,6 +40,7 @@ namespace Spine.Unity.Playables {
public class SpineAnimationStateMixerBehaviour : PlayableBehaviour { public class SpineAnimationStateMixerBehaviour : PlayableBehaviour {
float[] lastInputWeights; float[] lastInputWeights;
public int trackIndex;
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. // NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties.
public override void ProcessFrame (Playable playable, FrameData info, object playerData) { public override void ProcessFrame (Playable playable, FrameData info, object playerData) {
@ -80,10 +81,10 @@ namespace Spine.Unity.Playables {
if (clipData.animationReference == null) { if (clipData.animationReference == null) {
float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix; float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix;
state.SetEmptyAnimation(0, mixDuration); state.SetEmptyAnimation(trackIndex, mixDuration);
} else { } else {
if (clipData.animationReference.Animation != null) { if (clipData.animationReference.Animation != null) {
Spine.TrackEntry trackEntry = state.SetAnimation(0, clipData.animationReference.Animation, clipData.loop); Spine.TrackEntry trackEntry = state.SetAnimation(trackIndex, clipData.animationReference.Animation, clipData.loop);
//trackEntry.TrackTime = (float)inputPlayable.GetTime(); // More accurate time-start? //trackEntry.TrackTime = (float)inputPlayable.GetTime(); // More accurate time-start?
trackEntry.EventThreshold = clipData.eventThreshold; trackEntry.EventThreshold = clipData.eventThreshold;

View File

@ -38,8 +38,13 @@ namespace Spine.Unity.Playables {
[TrackClipType(typeof(SpineAnimationStateClip))] [TrackClipType(typeof(SpineAnimationStateClip))]
[TrackBindingType(typeof(SkeletonAnimation))] [TrackBindingType(typeof(SkeletonAnimation))]
public class SpineAnimationStateTrack : TrackAsset { public class SpineAnimationStateTrack : TrackAsset {
public int trackIndex = 0;
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) { public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) {
return ScriptPlayable<SpineAnimationStateMixerBehaviour>.Create (graph, inputCount); var scriptPlayable = ScriptPlayable<SpineAnimationStateMixerBehaviour>.Create(graph, inputCount);
var mixerBehaviour = scriptPlayable.GetBehaviour();
mixerBehaviour.trackIndex = this.trackIndex;
return scriptPlayable;
} }
} }
} }

View File

@ -52,8 +52,8 @@ namespace Spine.Unity.Playables {
var skeleton = playableHandle.Skeleton; var skeleton = playableHandle.Skeleton;
if (!m_FirstFrameHappened) { if (!m_FirstFrameHappened) {
defaultFlipX = skeleton.flipX; defaultFlipX = skeleton.FlipX;
defaultFlipY = skeleton.flipY; defaultFlipY = skeleton.FlipY;
m_FirstFrameHappened = true; m_FirstFrameHappened = true;
} }
@ -71,8 +71,8 @@ namespace Spine.Unity.Playables {
totalWeight += inputWeight; totalWeight += inputWeight;
if (inputWeight > greatestWeight) { if (inputWeight > greatestWeight) {
skeleton.flipX = input.flipX; skeleton.FlipX = input.flipX;
skeleton.flipY = input.flipY; skeleton.FlipY = input.flipY;
greatestWeight = inputWeight; greatestWeight = inputWeight;
} }
@ -81,8 +81,8 @@ namespace Spine.Unity.Playables {
} }
if (currentInputs != 1 && 1f - totalWeight > greatestWeight) { if (currentInputs != 1 && 1f - totalWeight > greatestWeight) {
skeleton.flipX = defaultFlipX; skeleton.FlipX = defaultFlipX;
skeleton.flipY = defaultFlipY; skeleton.FlipY = defaultFlipY;
} }
} }
@ -93,8 +93,8 @@ namespace Spine.Unity.Playables {
return; return;
var skeleton = playableHandle.Skeleton; var skeleton = playableHandle.Skeleton;
skeleton.flipX = defaultFlipX; skeleton.FlipX = defaultFlipX;
skeleton.flipY = defaultFlipY; skeleton.FlipY = defaultFlipY;
} }
} }