[unity] Added null-check at AnimationReferenceAsset.

This commit is contained in:
Harald Csaszar 2021-08-31 17:03:20 +02:00
parent d9b882eaef
commit d6df0725a2

View File

@ -55,7 +55,8 @@ namespace Spine.Unity {
public void Initialize () {
if (skeletonDataAsset == null) return;
this.animation = skeletonDataAsset.GetSkeletonData(AnimationReferenceAsset.QuietSkeletonData).FindAnimation(animationName);
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(AnimationReferenceAsset.QuietSkeletonData);
this.animation = skeletonData != null ? skeletonData.FindAnimation(animationName) : null;
if (this.animation == null) Debug.LogWarningFormat("Animation '{0}' not found in SkeletonData : {1}.", animationName, skeletonDataAsset.name);
}