瀏覽代碼

[unity] Further improved upon pull request #2351, commit 01273670. EditorSkeletonPlayer now provides alternative `Fixed Track Time` to set a specific frame.

Harald Csaszar 2 年之前
父節點
當前提交
cb154ed1ec
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Components/EditorSkeletonPlayer.cs

+ 12 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Components/EditorSkeletonPlayer.cs

@@ -44,6 +44,7 @@ namespace Spine.Unity {
 	public class EditorSkeletonPlayer : MonoBehaviour {
 	public class EditorSkeletonPlayer : MonoBehaviour {
 		public bool playWhenSelected = true;
 		public bool playWhenSelected = true;
 		public bool playWhenDeselected = true;
 		public bool playWhenDeselected = true;
+		public float fixedTrackTime = 0.0f;
 		private IEditorSkeletonWrapper skeletonWrapper;
 		private IEditorSkeletonWrapper skeletonWrapper;
 		private TrackEntry trackEntry;
 		private TrackEntry trackEntry;
 		private string oldAnimationName;
 		private string oldAnimationName;
@@ -85,6 +86,16 @@ namespace Spine.Unity {
 			EditorApplication.update -= EditorUpdate;
 			EditorApplication.update -= EditorUpdate;
 		}
 		}
 
 
+		private void Update () {
+			if (enabled == false || Application.isPlaying) return;
+			if (skeletonWrapper.State == null || skeletonWrapper.State.Tracks.Count == 0) return;
+
+			TrackEntry currentEntry = skeletonWrapper.State.Tracks.Items[0];
+			if (currentEntry != null && fixedTrackTime != 0) {
+				currentEntry.TrackTime = fixedTrackTime;
+			}
+		}
+
 		private void EditorUpdate () {
 		private void EditorUpdate () {
 			if (enabled == false || Application.isPlaying) return;
 			if (enabled == false || Application.isPlaying) return;
 			if (skeletonWrapper == null) return;
 			if (skeletonWrapper == null) return;
@@ -92,6 +103,7 @@ namespace Spine.Unity {
 			bool isSelected = Selection.Contains(this.gameObject);
 			bool isSelected = Selection.Contains(this.gameObject);
 			if (!this.playWhenSelected && isSelected) return;
 			if (!this.playWhenSelected && isSelected) return;
 			if (!this.playWhenDeselected && !isSelected) return;
 			if (!this.playWhenDeselected && !isSelected) return;
+			if (fixedTrackTime != 0) return;
 
 
 			// Update animation
 			// Update animation
 			if (oldAnimationName != skeletonWrapper.AnimationName || oldLoop != skeletonWrapper.Loop) {
 			if (oldAnimationName != skeletonWrapper.AnimationName || oldLoop != skeletonWrapper.Loop) {