Browse Source

Merge branch '4.1' of https://github.com/esotericsoftware/spine-runtimes into 4.1

Mario Zechner 3 năm trước cách đây
mục cha
commit
246e5a039b

+ 1 - 1
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs

@@ -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--;
 										}

+ 23 - 3
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs

@@ -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;
 								}

+ 5 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs

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

+ 11 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs

@@ -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);
+								}
+							}
+						}
 					}
 				}
 			}