Эх сурвалжийг харах

[unity] Fixed Skin created by GetRepackedSkin not copying bones list. Closes #1474.

Harald Csaszar 6 жил өмнө
parent
commit
159d71b827

+ 17 - 0
spine-csharp/src/ExposedList.cs

@@ -141,6 +141,23 @@ namespace Spine {
 			}
 		}
 
+		// Additional overload provided because ExposedList<T> only implements IEnumerable<T>,
+		// leading to sub-optimal behavior: It grows multiple times as it assumes not
+		// to know the final size ahead of insertion.
+		public void AddRange (ExposedList<T> list) {
+			CheckCollection(list);
+
+			int collectionCount = list.Count;
+			if (collectionCount == 0)
+				return;
+
+			GrowIfNeeded(collectionCount);
+			list.CopyTo(Items, Count);
+			Count += collectionCount;
+
+			version++;
+		}
+
 		public void AddRange (IEnumerable<T> collection) {
 			CheckCollection(collection);
 

+ 2 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs

@@ -324,6 +324,8 @@ namespace Spine.Unity.AttachmentTools {
 			var skinAttachments = o.Attachments;
 			var newSkin = new Skin(newName);
 
+			newSkin.bones.AddRange(o.bones);
+			
 			// Use these to detect and use shared regions.
 			var existingRegions = new Dictionary<AtlasRegion, int>();
 			var regionIndexes = new List<int>();