From d443ba4f537e06aac6d2730bb13d16906ac9a8da Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 15 Oct 2025 15:23:17 +0200 Subject: [PATCH] [csharp] Port of commits 139fd84 and 20d5ee6. Added allowMissingRegions to AtlasAttachmentLoader. See #2948. --- .../src/Attachments/AtlasAttachmentLoader.cs | 17 ++++++++++++----- spine-csharp/src/SkeletonBinary.cs | 6 +++--- spine-csharp/src/package.json | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs b/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs index 65c41cfd9..160555e7d 100644 --- a/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs +++ b/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs @@ -37,10 +37,16 @@ namespace Spine { /// public class AtlasAttachmentLoader : AttachmentLoader { private Atlas[] atlasArray; + public bool allowMissingRegions; - public AtlasAttachmentLoader (params Atlas[] atlasArray) { - if (atlasArray == null) throw new ArgumentNullException("atlas", "atlas array cannot be null."); + public AtlasAttachmentLoader (params Atlas[] atlasArray) + : this(false, atlasArray) { + } + + public AtlasAttachmentLoader (bool allowMissingRegions, params Atlas[] atlasArray) { + if (atlasArray == null) throw new ArgumentNullException ("atlas", "atlas array cannot be null."); this.atlasArray = atlasArray; + this.allowMissingRegions = allowMissingRegions; } private void LoadSequence (string name, string basePath, Sequence sequence) { @@ -48,7 +54,8 @@ namespace Spine { for (int i = 0, n = regions.Length; i < n; i++) { string path = sequence.GetPath(basePath, i); regions[i] = FindRegion(path); - if (regions[i] == null) throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name)); + if (regions[i] == null && !allowMissingRegions) + throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name)); } } @@ -58,7 +65,7 @@ namespace Spine { LoadSequence(name, path, sequence); else { AtlasRegion region = FindRegion(path); - if (region == null) + if (region == null && !allowMissingRegions) throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name)); attachment.Region = region; } @@ -71,7 +78,7 @@ namespace Spine { LoadSequence(name, path, sequence); else { AtlasRegion region = FindRegion(path); - if (region == null) + if (region == null && !allowMissingRegions) throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name)); attachment.Region = region; } diff --git a/spine-csharp/src/SkeletonBinary.cs b/spine-csharp/src/SkeletonBinary.cs index 497a2c580..c1d252b0c 100644 --- a/spine-csharp/src/SkeletonBinary.cs +++ b/spine-csharp/src/SkeletonBinary.cs @@ -461,7 +461,7 @@ namespace Spine { if (parent == null) throw new Exception("Parent mesh not found: " + linkedMesh.parent); linkedMesh.mesh.TimelineAttachment = linkedMesh.inheritTimelines ? (VertexAttachment)parent : linkedMesh.mesh; linkedMesh.mesh.ParentMesh = (MeshAttachment)parent; - if (linkedMesh.mesh.Sequence == null) linkedMesh.mesh.UpdateRegion(); + if (linkedMesh.mesh.Region != null) linkedMesh.mesh.UpdateRegion(); } linkedMeshes.Clear(); @@ -568,7 +568,7 @@ namespace Spine { region.height = height * scale; region.SetColor(color.RGBA8888ToColor()); region.sequence = sequence; - if (sequence == null) region.UpdateRegion(); + if (region.Region != null) region.UpdateRegion(); return region; } case AttachmentType.Boundingbox: { @@ -609,7 +609,7 @@ namespace Spine { mesh.WorldVerticesLength = vertices.length; mesh.triangles = triangles; mesh.regionUVs = uvs; - if (sequence == null) mesh.UpdateRegion(); + if (mesh.Region != null) mesh.UpdateRegion(); mesh.HullLength = hullLength << 1; mesh.Sequence = sequence; if (nonessential) { diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json index 83760f1cd..46375587f 100644 --- a/spine-csharp/src/package.json +++ b/spine-csharp/src/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-csharp", "displayName": "spine-csharp Runtime", "description": "This plugin provides the spine-csharp core runtime.", - "version": "4.3.9", + "version": "4.3.10", "unity": "2018.3", "author": { "name": "Esoteric Software",