From 1d2cad34a31cac4db09cfac22959e34cf1db48c1 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 23 Mar 2021 19:32:30 +0100 Subject: [PATCH] [unity] Fixed incorrect Timeline flip clip state when paused. Closes #1865. --- .../SpineSkeletonFlipMixerBehaviour.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs index a37b76fd1..415253f5e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs @@ -27,6 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_1_OR_NEWER +#define PLAYABLE_DIRECTOR_HAS_STOPPED_EVENT +#endif + using System; using UnityEngine; using UnityEngine.Playables; @@ -42,6 +46,31 @@ namespace Spine.Unity.Playables { SpinePlayableHandleBase playableHandle; bool m_FirstFrameHappened; +#if PLAYABLE_DIRECTOR_HAS_STOPPED_EVENT + PlayableDirector director = null; + + public override void OnPlayableCreate (Playable playable) { + director = playable.GetGraph().GetResolver() as PlayableDirector; + if (director) + director.stopped += OnDirectorStopped; + } + + public override void OnPlayableDestroy (Playable playable) { + if (director) + director.stopped -= OnDirectorStopped; + + base.OnPlayableDestroy(playable); + } + + void OnDirectorStopped (PlayableDirector obj) { + OnStop(); + } +#else + public override void OnGraphStop (Playable playable) { + OnStop(); + } +#endif + public override void ProcessFrame (Playable playable, FrameData info, object playerData) { playableHandle = playerData as SpinePlayableHandleBase; @@ -91,7 +120,7 @@ namespace Spine.Unity.Playables { skeleton.ScaleY = flipY ? -baseScaleY : baseScaleY; } - public override void OnGraphStop (Playable playable) { + public void OnStop () { m_FirstFrameHappened = false; if (playableHandle == null)