Browse Source

[Unity] Fixed `Initial Flip` not updating mesh in Editor mode. Closes #1953.

Harald Csaszar 3 năm trước cách đây
mục cha
commit
618e20dc9a

+ 0 - 8
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonAnimationInspector.cs

@@ -38,7 +38,6 @@ namespace Spine.Unity.Editor {
 	public class SkeletonAnimationInspector : SkeletonRendererInspector {
 		protected SerializedProperty animationName, loop, timeScale, autoReset;
 		protected bool wasAnimationParameterChanged = false;
-		protected bool requireRepaint;
 		readonly GUIContent LoopLabel = new GUIContent("Loop", "Whether or not .AnimationName should loop. This only applies to the initial animation specified in the inspector, or any subsequent Animations played through .AnimationName. Animations set through state.SetAnimation are unaffected.");
 		readonly GUIContent TimeScaleLabel = new GUIContent("Time Scale", "The rate at which animations progress over time. 1 means normal speed. 0.5 means 50% speed.");
 
@@ -79,13 +78,6 @@ namespace Spine.Unity.Editor {
 			SkeletonRootMotionParameter();
 
 			serializedObject.ApplyModifiedProperties();
-
-			if (!isInspectingPrefab) {
-				if (requireRepaint) {
-					UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
-					requireRepaint = false;
-				}
-			}
 		}
 
 		protected void TrySetAnimation (SkeletonAnimation skeletonAnimation) {

+ 31 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs

@@ -70,6 +70,8 @@ namespace Spine.Unity.Editor {
 		protected SerializedProperty maskInteraction;
 		protected SerializedProperty maskMaterialsNone, maskMaterialsInside, maskMaterialsOutside;
 		protected SpineInspectorUtility.SerializedSortingProperties sortingProperties;
+		protected bool wasInitParameterChanged = false;
+		protected bool requireRepaint = false;
 
 		protected bool isInspectingPrefab;
 		protected bool forceReloadQueued = false;
@@ -196,6 +198,13 @@ namespace Spine.Unity.Editor {
 					SceneView.RepaintAll();
 				}
 			}
+
+			if (!isInspectingPrefab) {
+				if (requireRepaint) {
+					UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
+					requireRepaint = false;
+				}
+			}
 		}
 
 		protected virtual void DrawInspectorGUI (bool multi) {
@@ -259,6 +268,9 @@ namespace Spine.Unity.Editor {
 
 			bool valid = TargetIsValid;
 
+			foreach (var o in targets)
+				ApplyModifiedMeshParameters(o as SkeletonRenderer);
+
 			// Fields.
 			if (multi) {
 				using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) {
@@ -330,8 +342,10 @@ namespace Spine.Unity.Editor {
 
 					using (new SpineInspectorUtility.IndentScope()) {
 						using (new EditorGUILayout.HorizontalScope()) {
+							EditorGUI.BeginChangeCheck();
 							SpineInspectorUtility.ToggleLeftLayout(initialFlipX);
 							SpineInspectorUtility.ToggleLeftLayout(initialFlipY);
+							wasInitParameterChanged |= EditorGUI.EndChangeCheck(); // Value used in the next update.
 							EditorGUILayout.Space();
 						}
 
@@ -421,6 +435,23 @@ namespace Spine.Unity.Editor {
 			}
 		}
 
+		protected void ApplyModifiedMeshParameters (SkeletonRenderer skeletonRenderer) {
+			if (skeletonRenderer == null) return;
+			if (!skeletonRenderer.valid)
+				return;
+
+			if (!isInspectingPrefab) {
+				if (wasInitParameterChanged) {
+					wasInitParameterChanged = false;
+					if (!Application.isPlaying) {
+						skeletonRenderer.Initialize(true);
+						skeletonRenderer.LateUpdate();
+						requireRepaint = true;
+					}
+				}
+			}
+		}
+
 		protected void SkeletonRootMotionParameter () {
 			SkeletonRootMotionParameter(targets);
 		}