mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fixed null reference exceptions after changes from compile-error bugfix commit 8770e319, see #1951.
This commit is contained in:
parent
cd8064774f
commit
4785dcc212
@ -361,7 +361,8 @@ namespace Spine.Unity.Editor {
|
|||||||
if (skeleton != null) {
|
if (skeleton != null) {
|
||||||
for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) {
|
for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) {
|
||||||
string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue;
|
string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue;
|
||||||
int index = skeleton.Data.FindSlot(slotName).Index;
|
SlotData slot = skeleton.Data.FindSlot(slotName);
|
||||||
|
int index = slot != null ? slot.Index : -1;
|
||||||
if (index == 0 || index == lastSlot) {
|
if (index == 0 || index == lastSlot) {
|
||||||
hasTerminalSlot = true;
|
hasTerminalSlot = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -483,7 +483,8 @@ namespace Spine.Unity.Editor {
|
|||||||
if (skeleton != null) {
|
if (skeleton != null) {
|
||||||
for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) {
|
for (int i = 0, n = separatorSlotNames.arraySize; i < n; i++) {
|
||||||
string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue;
|
string slotName = separatorSlotNames.GetArrayElementAtIndex(i).stringValue;
|
||||||
int index = skeleton.Data.FindSlot(slotName).Index;
|
SlotData slot = skeleton.Data.FindSlot(slotName);
|
||||||
|
int index = slot != null ? slot.Index : -1;
|
||||||
if (index == 0 || index == lastSlot) {
|
if (index == 0 || index == lastSlot) {
|
||||||
hasTerminalSlot = true;
|
hasTerminalSlot = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -53,7 +53,8 @@ namespace Spine.Unity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachment = skin.GetAttachment(skeleton.Data.FindSlot(slotName).Index, attachmentName);
|
Slot slot = skeleton.FindSlot(slotName);
|
||||||
|
var attachment = slot != null ? skin.GetAttachment(slot.Data.Index, attachmentName) : null;
|
||||||
if (attachment == null) {
|
if (attachment == null) {
|
||||||
Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.Name);
|
Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.Name);
|
||||||
return null;
|
return null;
|
||||||
@ -61,7 +62,6 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
var box = attachment as BoundingBoxAttachment;
|
var box = attachment as BoundingBoxAttachment;
|
||||||
if (box != null) {
|
if (box != null) {
|
||||||
var slot = skeleton.FindSlot(slotName);
|
|
||||||
return AddBoundingBoxGameObject(box.Name, box, slot, parent, isTrigger);
|
return AddBoundingBoxGameObject(box.Name, box, slot, parent, isTrigger);
|
||||||
} else {
|
} else {
|
||||||
Debug.LogFormat("Attachment '{0}' was not a Bounding Box.", attachmentName);
|
Debug.LogFormat("Attachment '{0}' was not a Bounding Box.", attachmentName);
|
||||||
|
|||||||
@ -252,10 +252,11 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) {
|
public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) {
|
||||||
var hierarchy = SpineAttachment.GetHierarchy(attachmentPath);
|
var hierarchy = SpineAttachment.GetHierarchy(attachmentPath);
|
||||||
return string.IsNullOrEmpty(hierarchy.name) ?
|
if (string.IsNullOrEmpty(hierarchy.name)) return null;
|
||||||
null :
|
|
||||||
skeletonData.FindSkin(hierarchy.skin).GetAttachment(
|
SlotData slot = skeletonData.FindSlot(hierarchy.slot);
|
||||||
skeletonData.FindSlot(hierarchy.slot).Index, hierarchy.name);
|
if (slot == null) return null;
|
||||||
|
return skeletonData.FindSkin(hierarchy.skin).GetAttachment(slot.Index, hierarchy.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spine.Attachment GetAttachment (string attachmentPath, SkeletonDataAsset skeletonDataAsset) {
|
public static Spine.Attachment GetAttachment (string attachmentPath, SkeletonDataAsset skeletonDataAsset) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user