[csharp] Port of commits 139fd84 and 20d5ee6. Added allowMissingRegions to AtlasAttachmentLoader. See #2948.

This commit is contained in:
Harald Csaszar 2025-10-15 15:23:17 +02:00
parent 54068d9d12
commit d443ba4f53
3 changed files with 16 additions and 9 deletions

View File

@ -37,10 +37,16 @@ namespace Spine {
/// </summary>
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;
}

View File

@ -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) {

View File

@ -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",