mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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)
|
if (atlas == null)
|
||||||
continue;
|
continue;
|
||||||
for (int i = 0; i < missingPaths.Count; i++) {
|
for (int i = 0; i < missingPaths.Count; i++) {
|
||||||
if (atlas.FindRegion(missingPaths[i]) != null) {
|
if (atlas.FindRegionIgnoringNumberSuffix(missingPaths[i]) != null) {
|
||||||
missingPaths.RemoveAt(i);
|
missingPaths.RemoveAt(i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,6 +221,26 @@ namespace Spine.Unity.Editor {
|
|||||||
return GetMatchingAtlas(requiredPaths, atlasAssets);
|
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) {
|
internal static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, List<AtlasAssetBase> atlasAssets) {
|
||||||
AtlasAssetBase atlasAssetMatch = null;
|
AtlasAssetBase atlasAssetMatch = null;
|
||||||
|
|
||||||
@ -228,7 +248,7 @@ namespace Spine.Unity.Editor {
|
|||||||
Atlas atlas = a.GetAtlas();
|
Atlas atlas = a.GetAtlas();
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
foreach (string regionPath in requiredPaths) {
|
foreach (string regionPath in requiredPaths) {
|
||||||
if (atlas.FindRegion(regionPath) == null) {
|
if (atlas.FindRegionIgnoringNumberSuffix(regionPath) == null) {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1118,7 +1138,7 @@ namespace Spine.Unity.Editor {
|
|||||||
foreach (var atlasAsset in atlasAssets) {
|
foreach (var atlasAsset in atlasAssets) {
|
||||||
var atlas = atlasAsset.GetAtlas();
|
var atlas = atlasAsset.GetAtlas();
|
||||||
for (int i = 0; i < missingRegions.Count; i++) {
|
for (int i = 0; i < missingRegions.Count; i++) {
|
||||||
if (atlas.FindRegion(missingRegions[i]) != null) {
|
if (atlas.FindRegionIgnoringNumberSuffix(missingRegions[i]) != null) {
|
||||||
missingRegions.RemoveAt(i);
|
missingRegions.RemoveAt(i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
@ -1152,7 +1172,7 @@ namespace Spine.Unity.Editor {
|
|||||||
var atlas = selectedAtlasAsset.GetAtlas();
|
var atlas = selectedAtlasAsset.GetAtlas();
|
||||||
bool hasValidRegion = false;
|
bool hasValidRegion = false;
|
||||||
foreach (string str in missingRegions) {
|
foreach (string str in missingRegions) {
|
||||||
if (atlas.FindRegion(str) != null) {
|
if (atlas.FindRegionIgnoringNumberSuffix(str) != null) {
|
||||||
hasValidRegion = true;
|
hasValidRegion = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -203,6 +203,11 @@ namespace Spine.Unity.Editor {
|
|||||||
var renderableAttachment = entry.Attachment as IHasTextureRegion;
|
var renderableAttachment = entry.Attachment as IHasTextureRegion;
|
||||||
if (renderableAttachment != null) {
|
if (renderableAttachment != null) {
|
||||||
var originalRegion = (AtlasRegion)renderableAttachment.Region;
|
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(
|
bool replacementExists = replacementMaterials.Exists(
|
||||||
replacement => replacement.pageName == originalRegion.page.name);
|
replacement => replacement.pageName == originalRegion.page.name);
|
||||||
if (!replacementExists) {
|
if (!replacementExists) {
|
||||||
|
|||||||
@ -127,8 +127,18 @@ namespace Spine.Unity {
|
|||||||
foreach (var entry in skinEntries) {
|
foreach (var entry in skinEntries) {
|
||||||
var renderableAttachment = entry.Attachment as IHasTextureRegion;
|
var renderableAttachment = entry.Attachment as IHasTextureRegion;
|
||||||
if (renderableAttachment != null) {
|
if (renderableAttachment != null) {
|
||||||
renderableAttachment.Region = CloneAtlasRegionWithMaterial(
|
if (renderableAttachment.Region != null) {
|
||||||
|
renderableAttachment.Region = CloneAtlasRegionWithMaterial(
|
||||||
(AtlasRegion)renderableAttachment.Region, replacementMaterials);
|
(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