mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[unity] Fixed Timeline SkeletonGraphic clip exception when DefaultMixDuration is disabled. Closes #2090. Added Unscaled Time property at Spine Timeline tracks.
This commit is contained in:
parent
cf654d3768
commit
d796131668
@ -85,7 +85,8 @@
|
|||||||
* Spine property Inspector fields (`Animation Name`, `Bone Name`, `Slot` and similar) now display the name in red when the respective animation/bone/etc no longer exists at the skeleton data. This may be helpful when such items have been renamed or deleted.
|
* Spine property Inspector fields (`Animation Name`, `Bone Name`, `Slot` and similar) now display the name in red when the respective animation/bone/etc no longer exists at the skeleton data. This may be helpful when such items have been renamed or deleted.
|
||||||
* Added `UnscaledTime` property at `SkeletonAnimation` as well, behaving like `SkeletonGraphic.UnscaledTime`. If enabled, AnimationState uses unscaled game time (`Time.unscaledDeltaTime`), running animations independent of e.g. game pause (`Time.timeScale`).
|
* Added `UnscaledTime` property at `SkeletonAnimation` as well, behaving like `SkeletonGraphic.UnscaledTime`. If enabled, AnimationState uses unscaled game time (`Time.unscaledDeltaTime`), running animations independent of e.g. game pause (`Time.timeScale`).
|
||||||
* `SkeletonAnimation`, `SkeletonMecanim` and `SkeletonGraphic` now provide an additional `OnAnimationRebuild` callback delegate which is issued after both the skeleton and the animation state have been initialized.
|
* `SkeletonAnimation`, `SkeletonMecanim` and `SkeletonGraphic` now provide an additional `OnAnimationRebuild` callback delegate which is issued after both the skeleton and the animation state have been initialized.
|
||||||
|
* Timeline `SkeletonAnimation Track` and `SkeletonGraphic Track` now provide an `Unscaled Time` property. Whenever starting a new animation clip of this track, `SkeletonAnimation.UnscaledTime` or `SkeletonGraphic.UnscaledTime` will be set to this value. This allows you to play back Timeline clips either in normal game time or unscaled game time. Note that `PlayableDirector.UpdateMethod` is ignored and replaced by this property, which allows more fine-granular control per Timeline track.
|
||||||
|
|
||||||
* **Breaking changes**
|
* **Breaking changes**
|
||||||
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
||||||
* `SkeletonGraphic` `OnRebuild` callback delegate is now issued after the skeleton has been initialized, before the `AnimationState` component is initialized. This makes behaviour consistent with `SkeletonAnimation` and `SkeletonMecanim` component behaviour. Use the new callback `OnAnimationRebuild` if you want to receive a callback after the `SkeletonGraphic` `AnimationState` has been initialized.
|
* `SkeletonGraphic` `OnRebuild` callback delegate is now issued after the skeleton has been initialized, before the `AnimationState` component is initialized. This makes behaviour consistent with `SkeletonAnimation` and `SkeletonMecanim` component behaviour. Use the new callback `OnAnimationRebuild` if you want to receive a callback after the `SkeletonGraphic` `AnimationState` has been initialized.
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
#endif
|
#endif
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Playables;
|
using UnityEngine.Playables;
|
||||||
using UnityEngine.Timeline;
|
using UnityEngine.Timeline;
|
||||||
@ -43,11 +44,26 @@ namespace Spine.Unity.Playables {
|
|||||||
#endif
|
#endif
|
||||||
public class SpineAnimationStateGraphicTrack : TrackAsset {
|
public class SpineAnimationStateGraphicTrack : TrackAsset {
|
||||||
public int trackIndex = 0;
|
public int trackIndex = 0;
|
||||||
|
[Tooltip("Whenever starting a new animation clip of this track, " +
|
||||||
|
"SkeletonGraphic.UnscaledTime will be set to this value. " +
|
||||||
|
"This allows you to play back Timeline clips either in normal game time " +
|
||||||
|
"or unscaled game time. Note that PlayableDirector.UpdateMethod " +
|
||||||
|
"is ignored and replaced by this property, which allows more fine-granular " +
|
||||||
|
"control per Timeline track.")]
|
||||||
|
public bool unscaledTime = false;
|
||||||
|
|
||||||
public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) {
|
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 scriptPlayable = ScriptPlayable<SpineAnimationStateMixerBehaviour>.Create(graph, inputCount);
|
||||||
var mixerBehaviour = scriptPlayable.GetBehaviour();
|
var mixerBehaviour = scriptPlayable.GetBehaviour();
|
||||||
mixerBehaviour.trackIndex = this.trackIndex;
|
mixerBehaviour.trackIndex = this.trackIndex;
|
||||||
|
mixerBehaviour.unscaledTime = this.unscaledTime;
|
||||||
return scriptPlayable;
|
return scriptPlayable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,7 @@ namespace Spine.Unity.Playables {
|
|||||||
float[] lastInputWeights;
|
float[] lastInputWeights;
|
||||||
bool lastAnyClipPlaying = false;
|
bool lastAnyClipPlaying = false;
|
||||||
public int trackIndex;
|
public int trackIndex;
|
||||||
|
public bool unscaledTime;
|
||||||
ScriptPlayable<SpineAnimationStateBehaviour>[] startingClips
|
ScriptPlayable<SpineAnimationStateBehaviour>[] startingClips
|
||||||
= new ScriptPlayable<SpineAnimationStateBehaviour>[2];
|
= new ScriptPlayable<SpineAnimationStateBehaviour>[2];
|
||||||
|
|
||||||
@ -177,6 +178,8 @@ namespace Spine.Unity.Playables {
|
|||||||
state.SetEmptyAnimation(trackIndex, mixDuration);
|
state.SetEmptyAnimation(trackIndex, mixDuration);
|
||||||
} else {
|
} else {
|
||||||
if (clipData.animationReference.Animation != null) {
|
if (clipData.animationReference.Animation != null) {
|
||||||
|
animationStateComponent.UnscaledTime = this.unscaledTime;
|
||||||
|
|
||||||
TrackEntry currentEntry = state.GetCurrent(trackIndex);
|
TrackEntry currentEntry = state.GetCurrent(trackIndex);
|
||||||
Spine.TrackEntry trackEntry;
|
Spine.TrackEntry trackEntry;
|
||||||
float customMixDuration = clipData.customDuration ? GetCustomMixDuration(clipData) : 0.0f;
|
float customMixDuration = clipData.customDuration ? GetCustomMixDuration(clipData) : 0.0f;
|
||||||
|
|||||||
@ -44,6 +44,13 @@ namespace Spine.Unity.Playables {
|
|||||||
#endif
|
#endif
|
||||||
public class SpineAnimationStateTrack : TrackAsset {
|
public class SpineAnimationStateTrack : TrackAsset {
|
||||||
public int trackIndex = 0;
|
public int trackIndex = 0;
|
||||||
|
[Tooltip("Whenever starting a new animation clip of this track, " +
|
||||||
|
"SkeletonAnimation.UnscaledTime will be set to this value. " +
|
||||||
|
"This allows you to play back Timeline clips either in normal game time " +
|
||||||
|
"or unscaled game time. Note that PlayableDirector.UpdateMethod " +
|
||||||
|
"is ignored and replaced by this property, which allows more fine-granular " +
|
||||||
|
"control per Timeline track.")]
|
||||||
|
public bool unscaledTime = false;
|
||||||
|
|
||||||
public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) {
|
public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) {
|
||||||
IEnumerable<TimelineClip> clips = this.GetClips();
|
IEnumerable<TimelineClip> clips = this.GetClips();
|
||||||
@ -56,6 +63,7 @@ namespace Spine.Unity.Playables {
|
|||||||
var scriptPlayable = ScriptPlayable<SpineAnimationStateMixerBehaviour>.Create(graph, inputCount);
|
var scriptPlayable = ScriptPlayable<SpineAnimationStateMixerBehaviour>.Create(graph, inputCount);
|
||||||
var mixerBehaviour = scriptPlayable.GetBehaviour();
|
var mixerBehaviour = scriptPlayable.GetBehaviour();
|
||||||
mixerBehaviour.trackIndex = this.trackIndex;
|
mixerBehaviour.trackIndex = this.trackIndex;
|
||||||
|
mixerBehaviour.unscaledTime = this.unscaledTime;
|
||||||
return scriptPlayable;
|
return scriptPlayable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user