From 8a6b75fb9affb1a07a9a3b930baff55532674531 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 12 Feb 2019 18:03:12 +0100 Subject: [PATCH 1/2] [unity] Updated Mix and Match documentation in code to mention that GetRepackedSkin() is expensive. --- spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs | 6 ++++-- .../spine-unity/Modules/AttachmentTools/AttachmentTools.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs index eeebe0d4b..a905cb7da 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs @@ -111,11 +111,13 @@ namespace Spine.Unity.Examples { // To prevent fallback from happening, make sure the key is not defined in the default skin. // STEP 3: APPLY AND CLEAN UP. - // Recommended: REPACK THE CUSTOM SKIN TO MINIMIZE DRAW CALLS + // Recommended, preferably at level-load-time: REPACK THE CUSTOM SKIN TO MINIMIZE DRAW CALLS + // IMPORTANT NOTE: the GetRepackedSkin() operation is expensive - if multiple characters + // need to call it every few seconds the overhead will outweigh the draw call benefits. + // // Repacking requires that you set all source textures/sprites/atlases to be Read/Write enabled in the inspector. // Combine all the attachment sources into one skin. Usually this means the default skin and the custom skin. // call Skin.GetRepackedSkin to get a cloned skin with cloned attachments that all use one texture. - // Under the hood, this relies on if (repack) { var repackedSkin = new Skin("repacked skin"); repackedSkin.AddAttachments(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index 766cec08b..918dda9e8 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -482,14 +482,14 @@ namespace Spine.Unity.Modules.AttachmentTools { /// /// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin. - /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them. + /// GetRepackedSkin is an expensive operation, preferably call it at level load time. No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them. public static Skin GetRepackedSkin (this Skin o, string newName, Material materialPropertySource, out Material outputMaterial, out Texture2D outputTexture, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, bool useOriginalNonrenderables = true) { return GetRepackedSkin(o, newName, materialPropertySource.shader, out outputMaterial, out outputTexture, maxAtlasSize, padding, textureFormat, mipmaps, materialPropertySource, useOriginalNonrenderables); } /// /// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin. - /// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them. + /// GetRepackedSkin is an expensive operation, preferably call it at level load time. No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them. public static Skin GetRepackedSkin (this Skin o, string newName, Shader shader, out Material outputMaterial, out Texture2D outputTexture, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, Material materialPropertySource = null, bool clearCache = false, bool useOriginalNonrenderables = true) { if (o == null) throw new System.NullReferenceException("Skin was null"); var skinAttachments = o.Attachments; From 30c511f53eff5823dc853c9d987c7e1d956cee93 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Wed, 13 Feb 2019 17:53:28 +0100 Subject: [PATCH 2/2] Javadoc. --- .../com/esotericsoftware/spine/AnimationState.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java index be1b96769..ce9e9035b 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -1232,7 +1232,8 @@ public class AnimationState { start, interrupt, end, dispose, complete, event } - /** The interface to implement for receiving TrackEntry events. + /** The interface to implement for receiving TrackEntry events. It is always safe to call AnimationState methods when receiving + * events. *

* See TrackEntry {@link TrackEntry#setListener(AnimationStateListener)} and AnimationState * {@link AnimationState#addListener(AnimationStateListener)}. */ @@ -1251,10 +1252,14 @@ public class AnimationState { * References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */ public void dispose (TrackEntry entry); - /** Invoked every time this entry's animation completes a loop. */ + /** Invoked every time this entry's animation completes a loop. Because this event is trigged in + * {@link AnimationState#apply(Skeleton)}, any animations set in response to the event won't be applied until the next time + * the AnimationState is applied. */ public void complete (TrackEntry entry); - /** Invoked when this entry's animation triggers an event. */ + /** Invoked when this entry's animation triggers an event. Because this event is trigged in + * {@link AnimationState#apply(Skeleton)}, any animations set in response to the event won't be applied until the next time + * the AnimationState is applied. */ public void event (TrackEntry entry, Event event); }