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 a0d4cd193..257809d9a 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -517,12 +517,19 @@ public class AnimationState { } /** Sets an empty animation for a track, discarding any queued animations, and sets the track entry's - * {@link TrackEntry#getMixDuration()}. + * {@link TrackEntry#getMixDuration()}. An empty animation has no timelines and serves as a placeholder for mixing in or out. *

- * Mixing out is done by setting an empty animation. A mix duration of 0 still mixes out over one frame. + * Mixing out is done by setting an empty animation with a mix duration using either {@link #setEmptyAnimation(int, float)}, + * {@link #setEmptyAnimations(float)}, or {@link #addEmptyAnimation(int, float, float)}. Mixing to an empty animation causes + * the previous animation to be applied less and less over the mix duration. Properties keyed in the previous animation + * transition to the value from lower tracks or to the setup pose value if no lower tracks key the property. A mix duration of + * 0 still mixes out over one frame. *

- * To mix in, first set an empty animation and add an animation using {@link #addAnimation(int, Animation, boolean, float)}, - * then set the {@link TrackEntry#setMixDuration(float)} on the returned track entry. */ + * Mixing in is done by first setting an empty animation, then adding an animation using + * {@link #addAnimation(int, Animation, boolean, float)} and on the returned track entry, set the + * {@link TrackEntry#setMixDuration(float)}. Mixing from an empty animation causes the new animation to be applied more and + * more over the mix duration. Properties keyed in the new animation transition from the value from lower tracks or from the + * setup pose value if no lower tracks key the property to the value keyed in the new animation. */ public TrackEntry setEmptyAnimation (int trackIndex, float mixDuration) { TrackEntry entry = setAnimation(trackIndex, emptyAnimation, false); entry.mixDuration = mixDuration; @@ -533,6 +540,8 @@ public class AnimationState { /** Adds an empty animation to be played after the current or last queued animation for a track, and sets the track entry's * {@link TrackEntry#getMixDuration()}. If the track is empty, it is equivalent to calling * {@link #setEmptyAnimation(int, float)}. + *

+ * See {@link #setEmptyAnimation(int, float)}. * @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation * duration of the previous track minus any mix duration plus delay. * @return A track entry to allow further customization of animation playback. References to the track entry must not be kept @@ -810,8 +819,8 @@ public class AnimationState { * is reached, no other animations are queued for playback, and mixing from any previous animations is complete, then the * properties keyed by the animation are set to the setup pose and the track is cleared. *

- * It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} to mix the properties back to the - * setup pose over time, rather than have it happen instantly. */ + * It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} rather than have the animation + * abruptly cease being applied. */ public float getTrackEnd () { return trackEnd; } diff --git a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java index 2879d27cf..d4c2a51cb 100644 --- a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java +++ b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java @@ -811,19 +811,19 @@ public class SkeletonViewer extends ApplicationAdapter { public boolean touchDown (int screenX, int screenY, int pointer, int button) { offsetX = screenX; - offsetY = Gdx.graphics.getHeight() - screenY; + offsetY = Gdx.graphics.getHeight() - 1 - screenY; return false; } public boolean touchDragged (int screenX, int screenY, int pointer) { float deltaX = screenX - offsetX; - float deltaY = Gdx.graphics.getHeight() - screenY - offsetY; + float deltaY = Gdx.graphics.getHeight() - 1 - screenY - offsetY; camera.position.x -= deltaX * camera.zoom; camera.position.y -= deltaY * camera.zoom; offsetX = screenX; - offsetY = Gdx.graphics.getHeight() - screenY; + offsetY = Gdx.graphics.getHeight() - 1 - screenY; return false; } diff --git a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs index d23a1f614..5c58ff055 100644 --- a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs @@ -230,9 +230,16 @@ namespace Spine.Unity.Editor { EditorApplication.hierarchyWindowItemOnGUI += HierarchyDragAndDrop; // Hierarchy Icons + #if UNITY_2017_2_OR_NEWER + EditorApplication.playModeStateChanged -= HierarchyIconsOnPlaymodeStateChanged; + EditorApplication.playModeStateChanged += HierarchyIconsOnPlaymodeStateChanged; + HierarchyIconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode); + #else EditorApplication.playmodeStateChanged -= HierarchyIconsOnPlaymodeStateChanged; EditorApplication.playmodeStateChanged += HierarchyIconsOnPlaymodeStateChanged; HierarchyIconsOnPlaymodeStateChanged(); + #endif + initialized = true; } @@ -255,7 +262,11 @@ namespace Spine.Unity.Editor { showHierarchyIcons = EditorGUILayout.Toggle(new GUIContent("Show Hierarchy Icons", "Show relevant icons on GameObjects with Spine Components on them. Disable this if you have large, complex scenes."), showHierarchyIcons); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, showHierarchyIcons); + #if UNITY_2017_2_OR_NEWER + HierarchyIconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode); + #else HierarchyIconsOnPlaymodeStateChanged(); + #endif } EditorGUILayout.Separator(); @@ -496,7 +507,11 @@ namespace Spine.Unity.Editor { #endregion #region Hierarchy + #if UNITY_2017_2_OR_NEWER + static void HierarchyIconsOnPlaymodeStateChanged (PlayModeStateChange stateChange) { + #else static void HierarchyIconsOnPlaymodeStateChanged () { + #endif skeletonRendererTable.Clear(); skeletonUtilityBoneTable.Clear(); boundingBoxFollowerTable.Clear(); diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index 0776572c6..985fcf8fa 100644 --- a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs +++ b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -113,37 +113,37 @@ namespace Spine.Unity.Modules.AttachmentTools { #region Runtime RegionAttachments ///

/// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses a new AtlasPage with the Material provided./// - public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material) { - return sprite.ToRegionAttachment(material.ToSpineAtlasPage()); + public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material, float rotation = 0f) { + return sprite.ToRegionAttachment(material.ToSpineAtlasPage(), rotation); } /// /// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses the AtlasPage provided./// - public static RegionAttachment ToRegionAttachment (this Sprite sprite, AtlasPage page) { + public static RegionAttachment ToRegionAttachment (this Sprite sprite, AtlasPage page, float rotation = 0f) { if (sprite == null) throw new System.ArgumentNullException("sprite"); if (page == null) throw new System.ArgumentNullException("page"); var region = sprite.ToAtlasRegion(page); var unitsPerPixel = 1f / sprite.pixelsPerUnit; - return region.ToRegionAttachment(sprite.name, unitsPerPixel); + return region.ToRegionAttachment(sprite.name, unitsPerPixel, rotation); } /// /// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate texture of the Sprite's texture data. Returns a RegionAttachment that uses it. Use this if you plan to use a premultiply alpha shader such as "Spine/Skeleton" - public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Shader shader, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps, Material materialPropertySource = null) { + public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Shader shader, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps, Material materialPropertySource = null, float rotation = 0f) { if (sprite == null) throw new System.ArgumentNullException("sprite"); if (shader == null) throw new System.ArgumentNullException("shader"); var region = sprite.ToAtlasRegionPMAClone(shader, textureFormat, mipmaps, materialPropertySource); var unitsPerPixel = 1f / sprite.pixelsPerUnit; - return region.ToRegionAttachment(sprite.name, unitsPerPixel); + return region.ToRegionAttachment(sprite.name, unitsPerPixel, rotation); } - public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Material materialPropertySource, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps) { - return sprite.ToRegionAttachmentPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource); + public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Material materialPropertySource, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps, float rotation = 0f) { + return sprite.ToRegionAttachmentPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource, rotation); } /// /// Creates a new RegionAttachment from a given AtlasRegion. - public static RegionAttachment ToRegionAttachment (this AtlasRegion region, string attachmentName, float scale = 0.01f) { + public static RegionAttachment ToRegionAttachment (this AtlasRegion region, string attachmentName, float scale = 0.01f, float rotation = 0f) { if (string.IsNullOrEmpty(attachmentName)) throw new System.ArgumentException("attachmentName can't be null or empty.", "attachmentName"); if (region == null) throw new System.ArgumentNullException("region"); @@ -162,14 +162,13 @@ namespace Spine.Unity.Modules.AttachmentTools { attachment.Path = region.name; attachment.scaleX = 1; attachment.scaleY = 1; - attachment.rotation = 0; + attachment.rotation = rotation; attachment.r = 1; attachment.g = 1; attachment.b = 1; attachment.a = 1; - // pass OriginalWidth and OriginalHeight because UpdateOffset uses it in its calculation. attachment.width = attachment.regionOriginalWidth * scale; attachment.height = attachment.regionOriginalHeight * scale; diff --git a/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc b/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc index f7ace1894..749b91bae 100644 --- a/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc +++ b/spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc @@ -344,8 +344,8 @@ VertexOutput vert(VertexInput input) output.pos = calculateLocalPos(input.vertex); output.color = calculateVertexColor(input.color); output.texcoord = float3(calculateTextureCoord(input.texcoord), 0); - - float3 viewPos = mul(UNITY_MATRIX_MV, input.vertex); + + float3 viewPos = UnityObjectViewPos(input.vertex); //float3 viewPos = mul(UNITY_MATRIX_MV, input.vertex); #if defined(FIXED_NORMALS_BACKFACE_RENDERING) || defined(_RIM_LIGHTING) float4 powWorld = calculateWorldPos(input.vertex); #endif