diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs
index 218bd3516..4ab24a88b 100644
--- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs
+++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs
@@ -97,19 +97,13 @@ namespace Spine.Unity {
if (string.IsNullOrEmpty(value)) {
state.ClearTrack(0);
} else {
- TrySetAnimation(value, loop);
+ var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(value);
+ if (animationObject != null)
+ state.SetAnimation(0, animationObject, loop);
}
}
}
- TrackEntry TrySetAnimation (string animationName, bool animationLoop) {
- var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(animationName);
- if (animationObject != null)
- return state.SetAnimation(0, animationObject, animationLoop);
-
- return null;
- }
-
/// Whether or not 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.
public bool loop;
@@ -153,27 +147,25 @@ namespace Spine.Unity {
return;
state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
-
- #if UNITY_EDITOR
+
if (!string.IsNullOrEmpty(_animationName)) {
- if (Application.isPlaying) {
- TrackEntry startingTrack = TrySetAnimation(_animationName, loop);
- if (startingTrack != null)
- Update(0);
- } else {
- // Assume SkeletonAnimation is valid for skeletonData and skeleton. Checked above.
- var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(_animationName);
- if (animationObject != null)
- animationObject.PoseSkeleton(skeleton, 0f);
+ var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(_animationName);
+ if (animationObject != null) {
+ animationObject.PoseSkeleton(skeleton, 0f);
+ skeleton.UpdateWorldTransform();
+
+ #if UNITY_EDITOR
+ if (Application.isPlaying) {
+ #endif
+
+ // Make this block not run in Unity Editor edit mode.
+ state.SetAnimation(0, animationObject, loop);
+
+ #if UNITY_EDITOR
+ }
+ #endif
}
}
- #else
- if (!string.IsNullOrEmpty(_animationName)) {
- TrackEntry startingTrack = TrySetAnimation(_animationName, loop);
- if (startingTrack != null)
- Update(0);
- }
- #endif
}
void Update () {
diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs
index 5d80c81e3..9b1f3f52c 100644
--- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs
+++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs
@@ -166,7 +166,8 @@ namespace Spine.Unity {
///
/// Clears the previously generated mesh and resets the skeleton's pose.
public virtual void ClearState () {
- meshFilter.sharedMesh = null;
+ var meshFilter = GetComponent();
+ if (meshFilter != null) meshFilter.sharedMesh = null;
currentInstructions.Clear();
if (skeleton != null) skeleton.SetToSetupPose();
}
@@ -193,7 +194,7 @@ namespace Spine.Unity {
valid = false;
}
- if (!skeletonDataAsset) {
+ if (skeletonDataAsset == null) {
if (logErrors) Debug.LogError("Missing SkeletonData asset.", this);
return;
}
diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs
index 109d1969f..7d44647f9 100644
--- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs
+++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs
@@ -244,24 +244,24 @@ namespace Spine.Unity {
if (!string.IsNullOrEmpty(initialSkinName))
skeleton.SetSkin(initialSkinName);
- #if UNITY_EDITOR
if (!string.IsNullOrEmpty(startingAnimation)) {
- if (Application.isPlaying) {
- state.SetAnimation(0, startingAnimation, startingLoop);
- } else {
- // Assume SkeletonAnimation is valid for skeletonData and skeleton. Checked above.
- var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(startingAnimation);
- if (animationObject != null)
- animationObject.PoseSkeleton(skeleton, 0);
+ var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(startingAnimation);
+ if (animationObject != null) {
+ animationObject.PoseSkeleton(skeleton, 0f);
+ skeleton.UpdateWorldTransform();
+
+ #if UNITY_EDITOR
+ if (Application.isPlaying) {
+ #endif
+
+ // Make this block not run in Unity Editor edit mode.
+ state.SetAnimation(0, animationObject, startingLoop);
+
+ #if UNITY_EDITOR
+ }
+ #endif
}
- Update(0);
}
- #else
- if (!string.IsNullOrEmpty(startingAnimation)) {
- state.SetAnimation(0, startingAnimation, startingLoop);
- Update(0);
- }
- #endif
}
public void UpdateMesh () {