|
@@ -37,7 +37,6 @@ namespace Spine.Unity.Editor {
|
|
|
[CanEditMultipleObjects]
|
|
|
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
|
|
protected SerializedProperty animationName, loop, timeScale, autoReset;
|
|
|
- protected bool wasAnimationNameChanged;
|
|
|
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.");
|
|
@@ -55,16 +54,13 @@ namespace Spine.Unity.Editor {
|
|
|
bool sameData = SpineInspectorUtility.TargetsUseSameData(serializedObject);
|
|
|
|
|
|
foreach (var o in targets)
|
|
|
- TrySetAnimation(o as SkeletonAnimation, multi);
|
|
|
- wasAnimationNameChanged = false;
|
|
|
+ TrySetAnimation(o as SkeletonAnimation);
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
if (!sameData) {
|
|
|
EditorGUILayout.DelayedTextField(animationName);
|
|
|
} else {
|
|
|
- EditorGUI.BeginChangeCheck();
|
|
|
EditorGUILayout.PropertyField(animationName);
|
|
|
- wasAnimationNameChanged |= EditorGUI.EndChangeCheck(); // Value used in the next update.
|
|
|
}
|
|
|
EditorGUILayout.PropertyField(loop, LoopLabel);
|
|
|
EditorGUILayout.PropertyField(timeScale, TimeScaleLabel);
|
|
@@ -76,20 +72,25 @@ namespace Spine.Unity.Editor {
|
|
|
EditorGUILayout.Space();
|
|
|
SkeletonRootMotionParameter();
|
|
|
|
|
|
+ serializedObject.ApplyModifiedProperties();
|
|
|
+
|
|
|
if (!isInspectingPrefab) {
|
|
|
if (requireRepaint) {
|
|
|
- SceneView.RepaintAll();
|
|
|
+ UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
|
|
|
requireRepaint = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected void TrySetAnimation (SkeletonAnimation skeletonAnimation, bool multi) {
|
|
|
+ protected void TrySetAnimation (SkeletonAnimation skeletonAnimation) {
|
|
|
if (skeletonAnimation == null) return;
|
|
|
if (!skeletonAnimation.valid)
|
|
|
return;
|
|
|
|
|
|
+ TrackEntry current = skeletonAnimation.AnimationState.GetCurrent(0);
|
|
|
if (!isInspectingPrefab) {
|
|
|
+ string activeAnimation = (current != null) ? current.Animation.Name : null;
|
|
|
+ bool wasAnimationNameChanged = activeAnimation != animationName.stringValue;
|
|
|
if (wasAnimationNameChanged) {
|
|
|
var skeleton = skeletonAnimation.Skeleton;
|
|
|
var state = skeletonAnimation.AnimationState;
|
|
@@ -105,7 +106,7 @@ namespace Spine.Unity.Editor {
|
|
|
if (animationToUse != null) {
|
|
|
skeletonAnimation.AnimationState.SetAnimation(0, animationToUse, loop.boolValue);
|
|
|
}
|
|
|
- skeleton.UpdateWorldTransform();
|
|
|
+ skeletonAnimation.Update(0);
|
|
|
skeletonAnimation.LateUpdate();
|
|
|
requireRepaint = true;
|
|
|
} else {
|
|
@@ -118,7 +119,6 @@ namespace Spine.Unity.Editor {
|
|
|
|
|
|
// Reflect animationName serialized property in the inspector even if SetAnimation API was used.
|
|
|
if (Application.isPlaying) {
|
|
|
- TrackEntry current = skeletonAnimation.AnimationState.GetCurrent(0);
|
|
|
if (current != null) {
|
|
|
if (skeletonAnimation.AnimationName != animationName.stringValue)
|
|
|
animationName.stringValue = current.Animation.Name;
|