Jelajahi Sumber

[unity] Fix AnimationReferenceAsset inspector without SkeletonDataAsset.

pharan 7 tahun lalu
induk
melakukan
d3a38367e1

+ 9 - 2
spine-unity/Assets/spine-unity/Editor/AnimationReferenceAssetEditor.cs

@@ -63,8 +63,15 @@ namespace Spine.Unity.Editor {
 		public override void OnInspectorGUI () {
 		public override void OnInspectorGUI () {
 			animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
 			animationNameProperty = animationNameProperty ?? serializedObject.FindProperty("animationName");
 			string animationName = animationNameProperty.stringValue;
 			string animationName = animationNameProperty.stringValue;
-			Animation animation = ThisSkeletonDataAsset.GetSkeletonData(true).FindAnimation(animationName);
-			bool animationNotFound = animation == null;
+
+			Animation animation = null;
+			if (ThisSkeletonDataAsset != null) {
+				var skeletonData = ThisSkeletonDataAsset.GetSkeletonData(true);
+				if (skeletonData != null) {
+					animation = skeletonData.FindAnimation(animationName);
+				}
+			} 
+			bool animationNotFound = (animation == null);
 
 
 			if (changeNextFrame) {
 			if (changeNextFrame) {
 				changeNextFrame = false;
 				changeNextFrame = false;