mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[unity] Fixed TK2D SpriteCollectionAttachmentLoader compile errors on 4.1. See #2113.
This commit is contained in:
parent
696c723013
commit
1549cdea5c
@ -28,9 +28,9 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#if SPINE_TK2D
|
||||
using Spine;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
// MITCH: handle TPackerCW flip mode (probably not swap uv horizontaly)
|
||||
namespace Spine.Unity.TK2D {
|
||||
@ -49,7 +49,7 @@ namespace Spine.Unity.TK2D {
|
||||
this.sprites = sprites;
|
||||
}
|
||||
|
||||
private void ProcessSpriteDefinition (String name) {
|
||||
private AtlasRegion ProcessSpriteDefinition (String name) {
|
||||
// Strip folder names.
|
||||
int index = name.LastIndexOfAny(new char[] { '/', '\\' });
|
||||
if (index != -1)
|
||||
@ -98,42 +98,62 @@ namespace Spine.Unity.TK2D {
|
||||
regionOffsetY = (int)((y1 - y0) / def.texelSize.y);
|
||||
|
||||
material = def.materialInst;
|
||||
}
|
||||
|
||||
public RegionAttachment NewRegionAttachment (Skin skin, String name, String path) {
|
||||
ProcessSpriteDefinition(path);
|
||||
|
||||
RegionAttachment region = new RegionAttachment(name);
|
||||
region.Path = path;
|
||||
region.RendererObject = material;
|
||||
region.SetUVs(u, v, u2, v2, regionRotated);
|
||||
region.RegionOriginalWidth = regionOriginalWidth;
|
||||
region.RegionOriginalHeight = regionOriginalHeight;
|
||||
region.RegionWidth = regionWidth;
|
||||
region.RegionHeight = regionHeight;
|
||||
region.RegionOffsetX = regionOffsetX;
|
||||
region.RegionOffsetY = regionOffsetY;
|
||||
AtlasRegion region = new AtlasRegion();
|
||||
region.name = name;
|
||||
AtlasPage page = new AtlasPage();
|
||||
page.rendererObject = material;
|
||||
region.page = page;
|
||||
region.u = u;
|
||||
region.u = v;
|
||||
region.u2 = u2;
|
||||
region.v2 = v2;
|
||||
region.rotate = regionRotated;
|
||||
region.degrees = regionRotated ? 90 : 0;
|
||||
region.originalWidth = (int)regionOriginalWidth;
|
||||
region.originalHeight = (int)regionOriginalHeight;
|
||||
region.width = (int)regionWidth;
|
||||
region.height = (int)regionHeight;
|
||||
region.offsetX = regionOffsetX;
|
||||
region.offsetY = regionOffsetY;
|
||||
return region;
|
||||
}
|
||||
|
||||
public MeshAttachment NewMeshAttachment (Skin skin, String name, String path) {
|
||||
ProcessSpriteDefinition(path);
|
||||
private void LoadSequence (string name, string basePath, Sequence sequence) {
|
||||
TextureRegion[] regions = sequence.Regions;
|
||||
for (int i = 0, n = regions.Length; i < n; i++) {
|
||||
string path = sequence.GetPath(basePath, i);
|
||||
regions[i] = ProcessSpriteDefinition(path);
|
||||
if (regions[i] == null) throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name));
|
||||
}
|
||||
}
|
||||
|
||||
MeshAttachment mesh = new MeshAttachment(name);
|
||||
mesh.Path = path;
|
||||
mesh.RendererObject = material;
|
||||
mesh.RegionU = u;
|
||||
mesh.RegionV = v;
|
||||
mesh.RegionU2 = u2;
|
||||
mesh.RegionV2 = v2;
|
||||
mesh.RegionRotate = regionRotated;
|
||||
mesh.RegionOriginalWidth = regionOriginalWidth;
|
||||
mesh.RegionOriginalHeight = regionOriginalHeight;
|
||||
mesh.RegionWidth = regionWidth;
|
||||
mesh.RegionHeight = regionHeight;
|
||||
mesh.RegionOffsetX = regionOffsetX;
|
||||
mesh.RegionOffsetY = regionOffsetY;
|
||||
return mesh;
|
||||
public RegionAttachment NewRegionAttachment (Skin skin, String name, String path, Sequence sequence) {
|
||||
RegionAttachment attachment = new RegionAttachment(name);
|
||||
if (sequence != null)
|
||||
LoadSequence(name, path, sequence);
|
||||
else {
|
||||
AtlasRegion region = ProcessSpriteDefinition(path);
|
||||
if (region == null)
|
||||
throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name));
|
||||
attachment.Region = region;
|
||||
attachment.Path = path;
|
||||
}
|
||||
return attachment;
|
||||
}
|
||||
|
||||
public MeshAttachment NewMeshAttachment (Skin skin, String name, String path, Sequence sequence) {
|
||||
MeshAttachment attachment = new MeshAttachment(name);
|
||||
if (sequence != null)
|
||||
LoadSequence(name, path, sequence);
|
||||
else {
|
||||
AtlasRegion region = ProcessSpriteDefinition(path);
|
||||
if (region == null)
|
||||
throw new ArgumentException(string.Format("Region not found in atlas: {0} (region attachment: {1})", path, name));
|
||||
attachment.Region = region;
|
||||
attachment.Path = path;
|
||||
}
|
||||
return attachment;
|
||||
}
|
||||
|
||||
public BoundingBoxAttachment NewBoundingBoxAttachment (Skin skin, String name) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user