mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[unity] Fixed issues with image sequence import, including custom slot blend modes. Closes #2126, closes #2127.
This commit is contained in:
parent
ec034a0654
commit
4f4d339c57
@ -669,7 +669,7 @@ namespace Spine.Unity.Editor {
|
||||
if (atlas == null)
|
||||
continue;
|
||||
for (int i = 0; i < missingPaths.Count; i++) {
|
||||
if (atlas.FindRegion(missingPaths[i]) != null) {
|
||||
if (atlas.FindRegionIgnoringNumberSuffix(missingPaths[i]) != null) {
|
||||
missingPaths.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
|
||||
@ -221,6 +221,26 @@ namespace Spine.Unity.Editor {
|
||||
return GetMatchingAtlas(requiredPaths, atlasAssets);
|
||||
}
|
||||
|
||||
internal static AtlasRegion FindRegionIgnoringNumberSuffix (this Atlas atlas, string regionPath) {
|
||||
AtlasRegion region = atlas.FindRegion(regionPath);
|
||||
if (region != null)
|
||||
return region;
|
||||
return atlas.FindRegionWithNumberSuffix(regionPath);
|
||||
}
|
||||
|
||||
internal static AtlasRegion FindRegionWithNumberSuffix (this Atlas atlas, string regionPath) {
|
||||
int pathLength = regionPath.Length;
|
||||
foreach (AtlasRegion region in atlas.Regions) {
|
||||
string name = region.name;
|
||||
if (name.StartsWith(regionPath)) {
|
||||
string suffix = name.Substring(pathLength);
|
||||
if (suffix.All(c => c >= '0' && c <= '9'))
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, List<AtlasAssetBase> atlasAssets) {
|
||||
AtlasAssetBase atlasAssetMatch = null;
|
||||
|
||||
@ -228,7 +248,7 @@ namespace Spine.Unity.Editor {
|
||||
Atlas atlas = a.GetAtlas();
|
||||
bool failed = false;
|
||||
foreach (string regionPath in requiredPaths) {
|
||||
if (atlas.FindRegion(regionPath) == null) {
|
||||
if (atlas.FindRegionIgnoringNumberSuffix(regionPath) == null) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
@ -1118,7 +1138,7 @@ namespace Spine.Unity.Editor {
|
||||
foreach (var atlasAsset in atlasAssets) {
|
||||
var atlas = atlasAsset.GetAtlas();
|
||||
for (int i = 0; i < missingRegions.Count; i++) {
|
||||
if (atlas.FindRegion(missingRegions[i]) != null) {
|
||||
if (atlas.FindRegionIgnoringNumberSuffix(missingRegions[i]) != null) {
|
||||
missingRegions.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
@ -1152,7 +1172,7 @@ namespace Spine.Unity.Editor {
|
||||
var atlas = selectedAtlasAsset.GetAtlas();
|
||||
bool hasValidRegion = false;
|
||||
foreach (string str in missingRegions) {
|
||||
if (atlas.FindRegion(str) != null) {
|
||||
if (atlas.FindRegionIgnoringNumberSuffix(str) != null) {
|
||||
hasValidRegion = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -203,6 +203,11 @@ namespace Spine.Unity.Editor {
|
||||
var renderableAttachment = entry.Attachment as IHasTextureRegion;
|
||||
if (renderableAttachment != null) {
|
||||
var originalRegion = (AtlasRegion)renderableAttachment.Region;
|
||||
Sequence sequence = null;
|
||||
if (originalRegion == null && (sequence = renderableAttachment.Sequence) != null) {
|
||||
if (sequence.Regions != null && sequence.Regions.Length > 0)
|
||||
originalRegion = (AtlasRegion)sequence.Regions[0];
|
||||
}
|
||||
bool replacementExists = replacementMaterials.Exists(
|
||||
replacement => replacement.pageName == originalRegion.page.name);
|
||||
if (!replacementExists) {
|
||||
|
||||
@ -127,8 +127,18 @@ namespace Spine.Unity {
|
||||
foreach (var entry in skinEntries) {
|
||||
var renderableAttachment = entry.Attachment as IHasTextureRegion;
|
||||
if (renderableAttachment != null) {
|
||||
renderableAttachment.Region = CloneAtlasRegionWithMaterial(
|
||||
if (renderableAttachment.Region != null) {
|
||||
renderableAttachment.Region = CloneAtlasRegionWithMaterial(
|
||||
(AtlasRegion)renderableAttachment.Region, replacementMaterials);
|
||||
} else {
|
||||
if (renderableAttachment.Sequence != null) {
|
||||
var regions = renderableAttachment.Sequence.Regions;
|
||||
for (int i = 0; i < regions.Length; ++i) {
|
||||
regions[i] = CloneAtlasRegionWithMaterial(
|
||||
(AtlasRegion)regions[i], replacementMaterials);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user