mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Update Timeline code.
This commit is contained in:
parent
e4eff73497
commit
13cb394353
@ -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;
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user