From 5bde0730d30b789fbc0d8c5da35899cfcc306fe5 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 24 Mar 2022 11:58:29 +0100 Subject: [PATCH] [unity] Timeline clips now offer an additional `Alpha` parameter for setting a custom constant mix alpha (as `TrackEntry.Alpha`). --- CHANGELOG.md | 1 + .../Editor/SpineAnimationStateDrawer.cs | 6 +++++- .../SpineAnimationState/SpineAnimationStateBehaviour.cs | 3 +++ .../SpineAnimationStateMixerBehaviour.cs | 4 +++- .../package-no-spine-unity-dependency.json | 2 +- .../com.esotericsoftware.spine.timeline/package.json | 2 +- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39acf1dbd..23d62ade5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,6 +165,7 @@ * Timeline track appearance and Inspector: Tracks now show icons and track colors to make them easier to distinguish. When a Track is selected, the Inspector now shows an editable track name which was previously only editable at the Timeline asset. * Added example component `SkeletonRenderTexture` to render a `SkeletonRenderer` to a `RenderTexture`, mainly for proper transparency. Added an example scene named `RenderTexture FadeOut Transparency` that demonstrates usage for a fadeout transparency effect. * Added another fadeout example component named `SkeletonRenderTextureFadeout` which takes over transparency fadeout when enabled. You can use this component as-is, attach it in disabled state and enable it to start a fadeout effect. + * Timeline clips now offer an additional `Alpha` parameter for setting a custom constant mix alpha value other than 1.0, just as `TrackEntry.Alpha`. Defaults to 1.0. * **Changes of default values** 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 7fc823add..1e08c1bb6 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs @@ -36,7 +36,7 @@ using UnityEngine; public class SpineAnimationStateDrawer : PropertyDrawer { public override float GetPropertyHeight (SerializedProperty property, GUIContent label) { - const int fieldCount = 15; + const int fieldCount = 16; return fieldCount * EditorGUIUtility.singleLineHeight; } @@ -48,6 +48,7 @@ public class SpineAnimationStateDrawer : PropertyDrawer { SerializedProperty useBlendDurationProp = property.FindPropertyRelative("useBlendDuration"); SerializedProperty mixDurationProp = property.FindPropertyRelative("mixDuration"); SerializedProperty holdPreviousProp = property.FindPropertyRelative("holdPrevious"); + SerializedProperty alphaProp = property.FindPropertyRelative("alpha"); SerializedProperty dontPauseWithDirectorProp = property.FindPropertyRelative("dontPauseWithDirector"); SerializedProperty dontEndWithClip = property.FindPropertyRelative("dontEndWithClip"); SerializedProperty endMixOutDuration = property.FindPropertyRelative("endMixOutDuration"); @@ -129,5 +130,8 @@ public class SpineAnimationStateDrawer : PropertyDrawer { singleFieldRect.y += lineHeightWithSpacing; EditorGUI.PropertyField(singleFieldRect, drawOrderProp); + + singleFieldRect.y += lineHeightWithSpacing; + EditorGUI.PropertyField(singleFieldRect, alphaProp); } } 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 0e76688b2..72b9394cc 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 @@ -69,6 +69,9 @@ namespace Spine.Unity.Playables { [Range(0, 1f)] public float drawOrderThreshold = 0.5f; + + [Range(0, 1f)] + public float alpha = 1.0f; } } 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 bf25ef008..8e62a3634 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 @@ -191,6 +191,7 @@ namespace Spine.Unity.Playables { trackEntry.TimeScale = (float)clipPlayable.GetSpeed(); trackEntry.AttachmentThreshold = clipData.attachmentThreshold; trackEntry.HoldPrevious = clipData.holdPrevious; + trackEntry.Alpha = clipData.alpha; if (clipData.customDuration) trackEntry.MixDuration = customMixDuration; @@ -286,6 +287,7 @@ namespace Spine.Unity.Playables { if (toAnimation != null) { toEntry = dummyAnimationState.SetAnimation(0, toAnimation, clipData.loop); toEntry.HoldPrevious = clipData.holdPrevious; + toEntry.Alpha = clipData.alpha; } } @@ -301,7 +303,7 @@ namespace Spine.Unity.Playables { dummyAnimationState.Apply(skeleton); } else { if (toAnimation != null) - toAnimation.Apply(skeleton, 0, toClipTime, clipData.loop, null, 1f, MixBlend.Setup, MixDirection.In); + toAnimation.Apply(skeleton, 0, toClipTime, clipData.loop, null, clipData.alpha, MixBlend.Setup, MixDirection.In); } if (skeletonAnimation) { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package-no-spine-unity-dependency.json b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package-no-spine-unity-dependency.json index bd8874dc9..2d6284d2c 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package-no-spine-unity-dependency.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package-no-spine-unity-dependency.json @@ -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 runtime (via the spine-unity unitypackage), version 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "4.0.9", + "version": "4.0.10", "unity": "2018.3", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json index 79a4e43c7..60146b620 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json @@ -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.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "4.0.9", + "version": "4.0.10", "unity": "2018.3", "author": { "name": "Esoteric Software",