瀏覽代碼

[unity] Timeline: Added SpineAnimationStateClip holdPrevious parameter. Closes #1775.

Harald Csaszar 4 年之前
父節點
當前提交
1b8a378f4f

+ 5 - 1
spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs

@@ -38,7 +38,7 @@ using Spine.Unity.Editor;
 public class SpineAnimationStateDrawer : PropertyDrawer {
 
 	public override float GetPropertyHeight (SerializedProperty property, GUIContent label) {
-		const int fieldCount = 10;
+		const int fieldCount = 11;
 		return fieldCount * EditorGUIUtility.singleLineHeight;
 	}
 
@@ -49,6 +49,7 @@ public class SpineAnimationStateDrawer : PropertyDrawer {
 		SerializedProperty customDurationProp = property.FindPropertyRelative("customDuration");
 		SerializedProperty useBlendDurationProp = property.FindPropertyRelative("useBlendDuration");
 		SerializedProperty mixDurationProp = property.FindPropertyRelative("mixDuration");
+		SerializedProperty holdPreviousProp = property.FindPropertyRelative("holdPrevious");
 		SerializedProperty eventProp = property.FindPropertyRelative("eventThreshold");
 		SerializedProperty attachmentProp = property.FindPropertyRelative("attachmentThreshold");
 		SerializedProperty drawOrderProp = property.FindPropertyRelative("drawOrderThreshold");
@@ -87,6 +88,9 @@ public class SpineAnimationStateDrawer : PropertyDrawer {
 			EditorGUI.PropertyField(singleFieldRect, mixDurationProp);
 		}
 
+		singleFieldRect.y += lineHeightWithSpacing;
+		EditorGUI.PropertyField(singleFieldRect, holdPreviousProp);
+
 		singleFieldRect.y += lineHeightWithSpacing;
 		EditorGUI.PropertyField(singleFieldRect, eventProp);
 

+ 1 - 0
spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs

@@ -52,6 +52,7 @@ namespace Spine.Unity.Playables {
 		private bool isInitialized = false; // required to read preferences values from editor side.
 		#pragma warning restore 414
 		public float mixDuration = 0.1f;
+		public bool holdPrevious = false;
 
 		[Range(0, 1f)]
 		public float attachmentThreshold = 0.5f;

+ 4 - 1
spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs

@@ -94,6 +94,7 @@ namespace Spine.Unity.Playables {
 							trackEntry.TrackTime = (float)inputPlayable.GetTime() * (float)inputPlayable.GetSpeed();
 							trackEntry.TimeScale = (float)inputPlayable.GetSpeed();
 							trackEntry.AttachmentThreshold = clipData.attachmentThreshold;
+							trackEntry.HoldPrevious = clipData.holdPrevious;
 
 							if (clipData.customDuration)
 								trackEntry.MixDuration = clipData.mixDuration;
@@ -182,8 +183,10 @@ namespace Spine.Unity.Playables {
 						dummyAnimationState.ClearTracks();
 						fromTrack = dummyAnimationState.SetAnimation(0, fromAnimation, fromClipLoop);
 						fromTrack.AllowImmediateQueue();
-						if (toAnimation != null)
+						if (toAnimation != null) {
 							toTrack = dummyAnimationState.SetAnimation(0, toAnimation, clipData.loop);
+							toTrack.HoldPrevious = clipData.holdPrevious;
+						}
 					}
 
 					// Update track times.