From cd3d8e33599f4c7cd217ee490a0d766b422800a4 Mon Sep 17 00:00:00 2001 From: Vladislav Hristov Date: Thu, 22 Jul 2021 12:10:45 +0300 Subject: [PATCH] [unity] Add option to not pause spine with timeline There is already an option with hold the animation, but there is no option to not pause the animation while the Timeline director is paused. An example use-case where this option is important is when the timeline is paused while waiting for an user input, but there is still a need to play an idle loop animation on a spine skeleton. --- .../Editor/SpineAnimationStateDrawer.cs | 4 ++++ .../SpineAnimationStateBehaviour.cs | 1 + .../SpineAnimationStateMixerBehaviour.cs | 11 ++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs index 6a4e940f9..0fbd1a6de 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs @@ -50,6 +50,7 @@ public class SpineAnimationStateDrawer : PropertyDrawer { SerializedProperty useBlendDurationProp = property.FindPropertyRelative("useBlendDuration"); SerializedProperty mixDurationProp = property.FindPropertyRelative("mixDuration"); SerializedProperty holdPreviousProp = property.FindPropertyRelative("holdPrevious"); + SerializedProperty dontPauseWithDirectorProp = property.FindPropertyRelative("dontPauseWithDirector"); SerializedProperty eventProp = property.FindPropertyRelative("eventThreshold"); SerializedProperty attachmentProp = property.FindPropertyRelative("attachmentThreshold"); SerializedProperty drawOrderProp = property.FindPropertyRelative("drawOrderThreshold"); @@ -91,6 +92,9 @@ public class SpineAnimationStateDrawer : PropertyDrawer { singleFieldRect.y += lineHeightWithSpacing; EditorGUI.PropertyField(singleFieldRect, holdPreviousProp); + singleFieldRect.y += lineHeightWithSpacing; + EditorGUI.PropertyField(singleFieldRect, dontPauseWithDirectorProp); + singleFieldRect.y += lineHeightWithSpacing; EditorGUI.PropertyField(singleFieldRect, eventProp); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs index 89eaddf39..beecbfee3 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs @@ -53,6 +53,7 @@ namespace Spine.Unity.Playables { #pragma warning restore 414 public float mixDuration = 0.1f; public bool holdPrevious = false; + public bool dontPauseWithDirector = false; [Range(0, 1f)] public float attachmentThreshold = 0.5f; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs index abe4f0d1b..4836827bd 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs @@ -41,14 +41,17 @@ namespace Spine.Unity.Playables { public int trackIndex; IAnimationStateComponent animationStateComponent; + bool dontPauseWithDirector = true; bool isPaused = false; TrackEntry pausedTrackEntry; float previousTimeScale = 1; public override void OnBehaviourPause (Playable playable, FrameData info) { - if (!isPaused) - HandlePause(playable); - isPaused = true; + if (!dontPauseWithDirector) { + if (!isPaused) + HandlePause(playable); + isPaused = true; + } } public override void OnBehaviourPlay (Playable playable, FrameData info) { @@ -119,6 +122,8 @@ namespace Spine.Unity.Playables { ScriptPlayable inputPlayable = (ScriptPlayable)playable.GetInput(i); SpineAnimationStateBehaviour clipData = inputPlayable.GetBehaviour(); + dontPauseWithDirector = clipData.dontPauseWithDirector; + if (clipData.animationReference == null) { float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix; state.SetEmptyAnimation(trackIndex, mixDuration);