|
@@ -37,6 +37,7 @@ namespace Spine.Unity.Editor {
|
|
[CanEditMultipleObjects]
|
|
[CanEditMultipleObjects]
|
|
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
|
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
|
protected SerializedProperty animationName, loop, timeScale, autoReset;
|
|
protected SerializedProperty animationName, loop, timeScale, autoReset;
|
|
|
|
+ protected bool wasAnimationParameterChanged = false;
|
|
protected bool requireRepaint;
|
|
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 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.");
|
|
readonly GUIContent TimeScaleLabel = new GUIContent("Time Scale", "The rate at which animations progress over time. 1 means normal speed. 0.5 means 50% speed.");
|
|
@@ -60,9 +61,14 @@ namespace Spine.Unity.Editor {
|
|
if (!sameData) {
|
|
if (!sameData) {
|
|
EditorGUILayout.DelayedTextField(animationName);
|
|
EditorGUILayout.DelayedTextField(animationName);
|
|
} else {
|
|
} else {
|
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
EditorGUILayout.PropertyField(animationName);
|
|
EditorGUILayout.PropertyField(animationName);
|
|
|
|
+ wasAnimationParameterChanged |= EditorGUI.EndChangeCheck(); // Value used in the next update.
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
EditorGUILayout.PropertyField(loop, LoopLabel);
|
|
EditorGUILayout.PropertyField(loop, LoopLabel);
|
|
|
|
+ wasAnimationParameterChanged |= EditorGUI.EndChangeCheck(); // Value used in the next update.
|
|
EditorGUILayout.PropertyField(timeScale, TimeScaleLabel);
|
|
EditorGUILayout.PropertyField(timeScale, TimeScaleLabel);
|
|
foreach (var o in targets) {
|
|
foreach (var o in targets) {
|
|
var component = o as SkeletonAnimation;
|
|
var component = o as SkeletonAnimation;
|
|
@@ -89,9 +95,12 @@ namespace Spine.Unity.Editor {
|
|
|
|
|
|
TrackEntry current = skeletonAnimation.AnimationState.GetCurrent(0);
|
|
TrackEntry current = skeletonAnimation.AnimationState.GetCurrent(0);
|
|
if (!isInspectingPrefab) {
|
|
if (!isInspectingPrefab) {
|
|
- string activeAnimation = (current != null) ? current.Animation.Name : null;
|
|
|
|
- bool wasAnimationNameChanged = activeAnimation != animationName.stringValue;
|
|
|
|
- if (wasAnimationNameChanged) {
|
|
|
|
|
|
+ string activeAnimation = (current != null) ? current.Animation.Name : "";
|
|
|
|
+ bool activeLoop = (current != null) ? current.Loop : false;
|
|
|
|
+ bool animationParameterChanged = this.wasAnimationParameterChanged &&
|
|
|
|
+ ((activeAnimation != animationName.stringValue) || (activeLoop != loop.boolValue));
|
|
|
|
+ if (animationParameterChanged) {
|
|
|
|
+ this.wasAnimationParameterChanged = false;
|
|
var skeleton = skeletonAnimation.Skeleton;
|
|
var skeleton = skeletonAnimation.Skeleton;
|
|
var state = skeletonAnimation.AnimationState;
|
|
var state = skeletonAnimation.AnimationState;
|
|
|
|
|