[unity] Fixed Timeline preview speed-scale applied twice in Unity 2019 and newer versions. Closes #2312.

This commit is contained in:
Harald Csaszar 2023-07-04 18:36:42 +02:00
parent 5635f31053
commit ccc41337f6
2 changed files with 18 additions and 2 deletions

View File

@ -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;
@ -212,7 +216,11 @@ namespace Spine.Unity.Playables {
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;
@ -283,12 +291,20 @@ namespace Spine.Unity.Playables {
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) {

View File

@ -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",