Skip to content

Commit

Permalink
[unity] Fixed Timeline preview speed-scale applied twice in Unity 201…
Browse files Browse the repository at this point in the history
…9 and newer versions. Closes EsotericSoftware#2312.
  • Loading branch information
HaraldCsaszar committed Jul 4, 2023
1 parent 5635f31 commit ccc4133
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -27,6 +27,10 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

#if UNITY_2019_1_OR_NEWER
#define SPEED_INCLUDED_IN_CLIP_TIME
#endif

#define SPINE_EDITMODEPOSE

using System;
Expand Down Expand Up @@ -212,7 +216,11 @@ ScriptPlayable<SpineAnimationStateBehaviour>[] startingClips
float clipSpeed = (float)clipPlayable.GetSpeed();
trackEntry.EventThreshold = clipData.eventThreshold;
trackEntry.DrawOrderThreshold = clipData.drawOrderThreshold;
trackEntry.TrackTime = (float)clipPlayable.GetTime() * clipSpeed * rootPlayableSpeed;
#if SPEED_INCLUDED_IN_CLIP_TIME
trackEntry.TrackTime = (float)clipPlayable.GetTime();
#else
trackEntry.TrackTime = (float)clipPlayable.GetTime() * rootPlayableSpeed * clipSpeed;
#endif
trackEntry.TimeScale = clipSpeed * rootPlayableSpeed;
trackEntry.AttachmentThreshold = clipData.attachmentThreshold;
trackEntry.HoldPrevious = clipData.holdPrevious;
Expand Down Expand Up @@ -283,12 +291,20 @@ ScriptPlayable<SpineAnimationStateBehaviour>[] startingClips
var fromClip = (ScriptPlayable<SpineAnimationStateBehaviour>)playable.GetInput(lastNonZeroWeightTrack - 1);
SpineAnimationStateBehaviour fromClipData = fromClip.GetBehaviour();
fromAnimation = fromClipData.animationReference != null ? fromClipData.animationReference.Animation : null;
#if SPEED_INCLUDED_IN_CLIP_TIME
fromClipTime = (float)fromClip.GetTime();
#else
fromClipTime = (float)fromClip.GetTime() * (float)fromClip.GetSpeed() * rootSpeed;
#endif
fromClipLoop = fromClipData.loop;
}

Animation toAnimation = clipData.animationReference != null ? clipData.animationReference.Animation : null;
#if SPEED_INCLUDED_IN_CLIP_TIME
float toClipTime = (float)inputPlayableClip.GetTime();
#else
float toClipTime = (float)inputPlayableClip.GetTime() * (float)inputPlayableClip.GetSpeed() * rootSpeed;
#endif
float mixDuration = clipData.mixDuration;

if (!clipData.customDuration && fromAnimation != null && toAnimation != null) {
Expand Down
Expand Up @@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.timeline",
"displayName": "Spine Timeline Extensions",
"description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity and spine-csharp runtimes as UPM packages (not as spine-unity unitypackage), version 4.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
"version": "4.1.8",
"version": "4.1.9",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
Expand Down

0 comments on commit ccc4133

Please sign in to comment.