mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[csharp] Port of commits 139fd84 and 20d5ee6. Added allowMissingRegions to AtlasAttachmentLoader. See #2948.
This commit is contained in:
parent
54068d9d12
commit
d443ba4f53
@ -37,10 +37,16 @@ namespace Spine {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AtlasAttachmentLoader : AttachmentLoader {
|
public class AtlasAttachmentLoader : AttachmentLoader {
|
||||||
private Atlas[] atlasArray;
|
private Atlas[] atlasArray;
|
||||||
|
public bool allowMissingRegions;
|
||||||
|
|
||||||
public AtlasAttachmentLoader (params Atlas[] atlasArray) {
|
public AtlasAttachmentLoader (params Atlas[] atlasArray)
|
||||||
if (atlasArray == null) throw new ArgumentNullException("atlas", "atlas array cannot be null.");
|
: 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.atlasArray = atlasArray;
|
||||||
|
this.allowMissingRegions = allowMissingRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSequence (string name, string basePath, Sequence sequence) {
|
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++) {
|
for (int i = 0, n = regions.Length; i < n; i++) {
|
||||||
string path = sequence.GetPath(basePath, i);
|
string path = sequence.GetPath(basePath, i);
|
||||||
regions[i] = FindRegion(path);
|
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);
|
LoadSequence(name, path, sequence);
|
||||||
else {
|
else {
|
||||||
AtlasRegion region = FindRegion(path);
|
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));
|
throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name));
|
||||||
attachment.Region = region;
|
attachment.Region = region;
|
||||||
}
|
}
|
||||||
@ -71,7 +78,7 @@ namespace Spine {
|
|||||||
LoadSequence(name, path, sequence);
|
LoadSequence(name, path, sequence);
|
||||||
else {
|
else {
|
||||||
AtlasRegion region = FindRegion(path);
|
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));
|
throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name));
|
||||||
attachment.Region = region;
|
attachment.Region = region;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -461,7 +461,7 @@ namespace Spine {
|
|||||||
if (parent == null) throw new Exception("Parent mesh not found: " + linkedMesh.parent);
|
if (parent == null) throw new Exception("Parent mesh not found: " + linkedMesh.parent);
|
||||||
linkedMesh.mesh.TimelineAttachment = linkedMesh.inheritTimelines ? (VertexAttachment)parent : linkedMesh.mesh;
|
linkedMesh.mesh.TimelineAttachment = linkedMesh.inheritTimelines ? (VertexAttachment)parent : linkedMesh.mesh;
|
||||||
linkedMesh.mesh.ParentMesh = (MeshAttachment)parent;
|
linkedMesh.mesh.ParentMesh = (MeshAttachment)parent;
|
||||||
if (linkedMesh.mesh.Sequence == null) linkedMesh.mesh.UpdateRegion();
|
if (linkedMesh.mesh.Region != null) linkedMesh.mesh.UpdateRegion();
|
||||||
}
|
}
|
||||||
linkedMeshes.Clear();
|
linkedMeshes.Clear();
|
||||||
|
|
||||||
@ -568,7 +568,7 @@ namespace Spine {
|
|||||||
region.height = height * scale;
|
region.height = height * scale;
|
||||||
region.SetColor(color.RGBA8888ToColor());
|
region.SetColor(color.RGBA8888ToColor());
|
||||||
region.sequence = sequence;
|
region.sequence = sequence;
|
||||||
if (sequence == null) region.UpdateRegion();
|
if (region.Region != null) region.UpdateRegion();
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
case AttachmentType.Boundingbox: {
|
case AttachmentType.Boundingbox: {
|
||||||
@ -609,7 +609,7 @@ namespace Spine {
|
|||||||
mesh.WorldVerticesLength = vertices.length;
|
mesh.WorldVerticesLength = vertices.length;
|
||||||
mesh.triangles = triangles;
|
mesh.triangles = triangles;
|
||||||
mesh.regionUVs = uvs;
|
mesh.regionUVs = uvs;
|
||||||
if (sequence == null) mesh.UpdateRegion();
|
if (mesh.Region != null) mesh.UpdateRegion();
|
||||||
mesh.HullLength = hullLength << 1;
|
mesh.HullLength = hullLength << 1;
|
||||||
mesh.Sequence = sequence;
|
mesh.Sequence = sequence;
|
||||||
if (nonessential) {
|
if (nonessential) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.spine-csharp",
|
"name": "com.esotericsoftware.spine.spine-csharp",
|
||||||
"displayName": "spine-csharp Runtime",
|
"displayName": "spine-csharp Runtime",
|
||||||
"description": "This plugin provides the spine-csharp core runtime.",
|
"description": "This plugin provides the spine-csharp core runtime.",
|
||||||
"version": "4.3.9",
|
"version": "4.3.10",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user