From 5d34140af5d5d1203831e057c6f88b7eea6934a3 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 24 Sep 2019 17:07:12 +0200 Subject: [PATCH] [unity] Fixed Skin created by GetRepackedSkin not copying bones list. Closes #1474. --- spine-csharp/src/ExposedList.cs | 17 +++++++++++++++++ .../spine-unity/Utility/AtlasUtilities.cs | 2 ++ 2 files changed, 19 insertions(+) diff --git a/spine-csharp/src/ExposedList.cs b/spine-csharp/src/ExposedList.cs index 9bec2297a..7d0b69711 100644 --- a/spine-csharp/src/ExposedList.cs +++ b/spine-csharp/src/ExposedList.cs @@ -141,6 +141,23 @@ namespace Spine { } } + // Additional overload provided because ExposedList only implements IEnumerable, + // 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 list) { + CheckCollection(list); + + int collectionCount = list.Count; + if (collectionCount == 0) + return; + + GrowIfNeeded(collectionCount); + list.CopyTo(Items, Count); + Count += collectionCount; + + version++; + } + public void AddRange (IEnumerable collection) { CheckCollection(collection); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs index b5371e031..64cb5ead9 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs +++ b/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(); var regionIndexes = new List();