From bb7d131c28d53681cfec3c70a81668467bd80f9f Mon Sep 17 00:00:00 2001 From: John Date: Tue, 29 Dec 2015 04:46:36 +0800 Subject: [PATCH] [Unity] AnimationName warnings https://github.com/EsotericSoftware/spine-runtimes/issues/444 This makes AnimationName getter and setter safer but still warns the user of unusual circumstances. --- spine-unity/Assets/spine-unity/SkeletonAnimation.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimation.cs b/spine-unity/Assets/spine-unity/SkeletonAnimation.cs index d85c569d5..1d2162b73 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimation.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimation.cs @@ -72,6 +72,11 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation { public String AnimationName { get { + if (!valid) { + Debug.LogWarning("You tried access AnimationName but the SkeletonAnimation was not valid. Try checking your Skeleton Data for errors."); + return null; + } + TrackEntry entry = state.GetCurrent(0); return entry == null ? null : entry.Animation.Name; } @@ -79,6 +84,12 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation { if (_animationName == value) return; _animationName = value; + + if (!valid) { + Debug.LogWarning("You tried to change AnimationName but the SkeletonAnimation was not valid. Try checking your Skeleton Data for errors."); + return; + } + if (value == null || value.Length == 0) state.ClearTrack(0); else