diff --git a/spine-unity/Assets/Plugins/Editor/Spine/SkeletonComponentInspector.cs b/spine-unity/Assets/Plugins/Editor/Spine/SkeletonComponentInspector.cs index 16d8655e2..80c43e3a2 100644 --- a/spine-unity/Assets/Plugins/Editor/Spine/SkeletonComponentInspector.cs +++ b/spine-unity/Assets/Plugins/Editor/Spine/SkeletonComponentInspector.cs @@ -74,11 +74,14 @@ public class SkeletonComponentInspector : Editor { EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(timeScale); - - if (serializedObject.ApplyModifiedProperties() || - (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") - ) { - component.Clear(); + + if (!Application.isPlaying) { + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + component.Clear(); + component.Update(); + } } } } diff --git a/spine-unity/Assets/Plugins/Editor/Spine/SkeletonDataAssetInspector.cs b/spine-unity/Assets/Plugins/Editor/Spine/SkeletonDataAssetInspector.cs index a372ff9bc..10903394e 100644 --- a/spine-unity/Assets/Plugins/Editor/Spine/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/Plugins/Editor/Spine/SkeletonDataAssetInspector.cs @@ -78,19 +78,21 @@ public class SkeletonDataAssetInspector : Editor { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Mix")) { - duration.InsertArrayElementAtIndex(fromAnimation.arraySize); - toAnimation.InsertArrayElementAtIndex(fromAnimation.arraySize); - fromAnimation.InsertArrayElementAtIndex(fromAnimation.arraySize); + duration.arraySize++; + toAnimation.arraySize++; + fromAnimation.arraySize++; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } } - if (serializedObject.ApplyModifiedProperties() || - (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") - ) { - asset.Clear(); + if (!Application.isPlaying) { + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + asset.Clear(); + } } } } diff --git a/spine-unity/Assets/Plugins/Spine/AtlasAsset.cs b/spine-unity/Assets/Plugins/Spine/AtlasAsset.cs index 3b46ad44d..400e98f9d 100644 --- a/spine-unity/Assets/Plugins/Spine/AtlasAsset.cs +++ b/spine-unity/Assets/Plugins/Spine/AtlasAsset.cs @@ -56,8 +56,8 @@ public class AtlasAsset : ScriptableObject { try { atlas = new Atlas(new StringReader(atlasFile.text), "", new SingleTextureLoader(material)); return atlas; - } catch (Exception) { - Debug.LogException(new Exception("Error reading atlas file for atlas asset: " + name), this); + } catch (Exception ex) { + Debug.Log("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this); return null; } } diff --git a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs index 6f56fac8b..63c88bf59 100644 --- a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs @@ -60,14 +60,21 @@ public class SkeletonComponent : MonoBehaviour { skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false)); } - + + public void UpdateAnimation () { + skeleton.Update(Time.deltaTime * timeScale); + state.Update(Time.deltaTime * timeScale); + state.Apply(skeleton); + skeleton.UpdateWorldTransform(); + } + public void Update () { // Clear fields if missing information to render. if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(false) == null) { Clear(); return; } - + // Initialize fields. if (skeleton == null || skeleton.Data != skeletonDataAsset.GetSkeletonData(false)) Initialize(); @@ -81,12 +88,8 @@ public class SkeletonComponent : MonoBehaviour { state.SetAnimation(animation, loop); } state.Loop = loop; - - // Apply animation. - skeleton.Update(Time.deltaTime * timeScale); - state.Update(Time.deltaTime * timeScale); - state.Apply(skeleton); - skeleton.UpdateWorldTransform(); + + UpdateAnimation(); // Count quads. int quadCount = 0; diff --git a/spine-unity/Assets/Plugins/Spine/SkeletonDataAsset.cs b/spine-unity/Assets/Plugins/Spine/SkeletonDataAsset.cs index 83aae6823..e486aa7ce 100644 --- a/spine-unity/Assets/Plugins/Spine/SkeletonDataAsset.cs +++ b/spine-unity/Assets/Plugins/Spine/SkeletonDataAsset.cs @@ -73,13 +73,15 @@ public class SkeletonDataAsset : ScriptableObject { skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text)); } catch (Exception ex) { if (!quiet) - Debug.LogException(new Exception("Error reading skeleton JSON file for skeleton data asset: " + name, ex), this); + Debug.Log("Error reading skeleton JSON file for skeleton data asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this); return null; } stateData = new AnimationStateData(skeletonData); - for (int i = 0, n = fromAnimation.Length; i < n; i++) + for (int i = 0, n = fromAnimation.Length; i < n; i++) { + if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue; stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]); + } return skeletonData; }