mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 08:38:43 +08:00
[unity] Fixed Timeline clip not updating to the shown EaseIn & MixerBehaviour when inside Play mode. Added null check. Closes #1962.
This commit is contained in:
parent
d296fa3efa
commit
5937b3021b
@ -109,7 +109,12 @@ public class SpineAnimationStateDrawer : PropertyDrawer {
|
||||
EditorGUI.PropertyField(singleFieldRect, useBlendDurationProp);
|
||||
|
||||
singleFieldRect.y += lineHeightWithSpacing;
|
||||
EditorGUI.PropertyField(singleFieldRect, mixDurationProp);
|
||||
|
||||
bool greyOutMixDuration = (!useBlendDurationProp.hasMultipleDifferentValues &&
|
||||
useBlendDurationProp.boolValue == true);
|
||||
using (new EditorGUI.DisabledGroupScope(greyOutMixDuration)) {
|
||||
EditorGUI.PropertyField(singleFieldRect, mixDurationProp);
|
||||
}
|
||||
}
|
||||
|
||||
singleFieldRect.y += lineHeightWithSpacing;
|
||||
|
||||
@ -41,6 +41,9 @@ namespace Spine.Unity.Playables {
|
||||
|
||||
[Serializable]
|
||||
public class SpineAnimationStateBehaviour : PlayableBehaviour {
|
||||
|
||||
[NonSerialized] public TimelineClip timelineClip;
|
||||
|
||||
public AnimationReferenceAsset animationReference;
|
||||
public bool loop;
|
||||
|
||||
|
||||
@ -38,8 +38,11 @@ namespace Spine.Unity.Playables {
|
||||
public SpineAnimationStateBehaviour template = new SpineAnimationStateBehaviour();
|
||||
|
||||
public ClipCaps clipCaps { get { return ClipCaps.Blending | ClipCaps.ClipIn | ClipCaps.SpeedMultiplier | (template.loop ? ClipCaps.Looping : 0); } }
|
||||
[NonSerialized] public TimelineClip timelineClip;
|
||||
|
||||
public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) {
|
||||
template.timelineClip = this.timelineClip;
|
||||
|
||||
var playable = ScriptPlayable<SpineAnimationStateBehaviour>.Create(graph, template);
|
||||
playable.GetBehaviour();
|
||||
return playable;
|
||||
|
||||
@ -95,6 +95,8 @@ namespace Spine.Unity.Playables {
|
||||
}
|
||||
|
||||
protected void HandleClipEnd () {
|
||||
if (animationStateComponent == null) return;
|
||||
|
||||
var state = animationStateComponent.AnimationState;
|
||||
if (endAtClipEnd &&
|
||||
timelineStartedTrackEntry != null &&
|
||||
@ -172,13 +174,14 @@ namespace Spine.Unity.Playables {
|
||||
endMixOutDuration = clipData.endMixOutDuration;
|
||||
|
||||
if (clipData.animationReference == null) {
|
||||
float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix;
|
||||
float mixDuration = clipData.customDuration ? GetCustomMixDuration(clipData) : state.Data.DefaultMix;
|
||||
state.SetEmptyAnimation(trackIndex, mixDuration);
|
||||
} else {
|
||||
if (clipData.animationReference.Animation != null) {
|
||||
TrackEntry currentEntry = state.GetCurrent(trackIndex);
|
||||
Spine.TrackEntry trackEntry;
|
||||
if (currentEntry == null && (clipData.customDuration && clipData.mixDuration > 0)) {
|
||||
float customMixDuration = clipData.customDuration ? GetCustomMixDuration(clipData) : 0.0f;
|
||||
if (currentEntry == null && customMixDuration > 0) {
|
||||
state.SetEmptyAnimation(trackIndex, 0); // ease in requires empty animation
|
||||
trackEntry = state.AddAnimation(trackIndex, clipData.animationReference.Animation, clipData.loop, 0);
|
||||
} else
|
||||
@ -192,7 +195,7 @@ namespace Spine.Unity.Playables {
|
||||
trackEntry.HoldPrevious = clipData.holdPrevious;
|
||||
|
||||
if (clipData.customDuration)
|
||||
trackEntry.MixDuration = clipData.mixDuration;
|
||||
trackEntry.MixDuration = customMixDuration;
|
||||
|
||||
timelineStartedTrackEntry = trackEntry;
|
||||
}
|
||||
@ -314,6 +317,14 @@ namespace Spine.Unity.Playables {
|
||||
}
|
||||
#endif
|
||||
|
||||
float GetCustomMixDuration (SpineAnimationStateBehaviour clipData) {
|
||||
if (clipData.useBlendDuration) {
|
||||
TimelineClip clip = clipData.timelineClip;
|
||||
return (float)Math.Max(clip.blendInDuration, clip.easeInDuration);
|
||||
} else {
|
||||
return clipData.mixDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
@ -39,6 +40,13 @@ namespace Spine.Unity.Playables {
|
||||
public int trackIndex = 0;
|
||||
|
||||
public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) {
|
||||
IEnumerable<TimelineClip> clips = this.GetClips();
|
||||
foreach (TimelineClip clip in clips) {
|
||||
var animationStateClip = clip.asset as SpineAnimationStateClip;
|
||||
if (animationStateClip != null)
|
||||
animationStateClip.timelineClip = clip;
|
||||
}
|
||||
|
||||
var scriptPlayable = ScriptPlayable<SpineAnimationStateMixerBehaviour>.Create(graph, inputCount);
|
||||
var mixerBehaviour = scriptPlayable.GetBehaviour();
|
||||
mixerBehaviour.trackIndex = this.trackIndex;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user