diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java index 1a2b55eb4..c4114faee 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java @@ -585,7 +585,7 @@ public class SkeletonBinary extends SkeletonLoader { region.setHeight(height * scale); Color.rgba8888ToColor(region.getColor(), color); region.setSequence(sequence); - if (sequence == null) region.updateRegion(); + if (region.getRegion() != null) region.updateRegion(); yield region; } case boundingbox -> { @@ -626,7 +626,7 @@ public class SkeletonBinary extends SkeletonLoader { mesh.setWorldVerticesLength(vertices.length); mesh.setTriangles(triangles); mesh.setRegionUVs(uvs); - if (sequence == null) mesh.updateRegion(); + if (mesh.getRegion() != null) mesh.updateRegion(); mesh.setHullLength(hullLength << 1); mesh.setSequence(sequence); if (nonessential) { diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/AtlasAttachmentLoader.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/AtlasAttachmentLoader.java index 16c0e5f53..572e3a928 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/AtlasAttachmentLoader.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/AtlasAttachmentLoader.java @@ -43,10 +43,16 @@ import com.esotericsoftware.spine.Skin; @SuppressWarnings("javadoc") public class AtlasAttachmentLoader implements AttachmentLoader { private TextureAtlas atlas; + public boolean allowMissingRegions; public AtlasAttachmentLoader (TextureAtlas atlas) { + this(atlas, false); + } + + public AtlasAttachmentLoader (TextureAtlas atlas, boolean allowMissingRegions) { if (atlas == null) throw new IllegalArgumentException("atlas cannot be null."); this.atlas = atlas; + this.allowMissingRegions = allowMissingRegions; } private void loadSequence (String name, String basePath, Sequence sequence) { @@ -54,7 +60,11 @@ public class AtlasAttachmentLoader implements AttachmentLoader { for (int i = 0, n = regions.length; i < n; i++) { String path = sequence.getPath(basePath, i); regions[i] = atlas.findRegion(path); - if (regions[i] == null) throw new RuntimeException("Region not found in atlas: " + path + " (sequence: " + name + ")"); + if (regions[i] == null) { + if (!allowMissingRegions) + throw new RuntimeException("Region not found in atlas: " + path + " (sequence: " + name + ")"); + continue; + } } } @@ -64,7 +74,7 @@ public class AtlasAttachmentLoader implements AttachmentLoader { loadSequence(name, path, sequence); else { AtlasRegion region = atlas.findRegion(path); - if (region == null) + if (region == null && !allowMissingRegions) throw new RuntimeException("Region not found in atlas: " + path + " (region attachment: " + name + ")"); attachment.setRegion(region); } @@ -77,7 +87,7 @@ public class AtlasAttachmentLoader implements AttachmentLoader { loadSequence(name, path, sequence); else { AtlasRegion region = atlas.findRegion(path); - if (region == null) + if (region == null && !allowMissingRegions) throw new RuntimeException("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); attachment.setRegion(region); }