Merge branch '3.6' into 3.7-beta

This commit is contained in:
NathanSweet 2017-10-20 22:13:07 +02:00
commit 3b3527ffc7
5 changed files with 45 additions and 22 deletions

View File

@ -517,12 +517,19 @@ public class AnimationState {
} }
/** Sets an empty animation for a track, discarding any queued animations, and sets the track entry's /** 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.
* <p> * <p>
* 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.
* <p> * <p>
* To mix in, first set an empty animation and add an animation using {@link #addAnimation(int, Animation, boolean, float)}, * Mixing in is done by first setting an empty animation, then adding an animation using
* then set the {@link TrackEntry#setMixDuration(float)} on the returned track entry. */ * {@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) { public TrackEntry setEmptyAnimation (int trackIndex, float mixDuration) {
TrackEntry entry = setAnimation(trackIndex, emptyAnimation, false); TrackEntry entry = setAnimation(trackIndex, emptyAnimation, false);
entry.mixDuration = mixDuration; 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 /** 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 TrackEntry#getMixDuration()}. If the track is empty, it is equivalent to calling
* {@link #setEmptyAnimation(int, float)}. * {@link #setEmptyAnimation(int, float)}.
* <p>
* 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 * @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 <code>delay</code>. * duration of the previous track minus any mix duration plus <code>delay</code>.
* @return A track entry to allow further customization of animation playback. References to the track entry must not be kept * @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 * 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. * properties keyed by the animation are set to the setup pose and the track is cleared.
* <p> * <p>
* It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} to mix the properties back to the * It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} rather than have the animation
* setup pose over time, rather than have it happen instantly. */ * abruptly cease being applied. */
public float getTrackEnd () { public float getTrackEnd () {
return trackEnd; return trackEnd;
} }

View File

@ -811,19 +811,19 @@ public class SkeletonViewer extends ApplicationAdapter {
public boolean touchDown (int screenX, int screenY, int pointer, int button) { public boolean touchDown (int screenX, int screenY, int pointer, int button) {
offsetX = screenX; offsetX = screenX;
offsetY = Gdx.graphics.getHeight() - screenY; offsetY = Gdx.graphics.getHeight() - 1 - screenY;
return false; return false;
} }
public boolean touchDragged (int screenX, int screenY, int pointer) { public boolean touchDragged (int screenX, int screenY, int pointer) {
float deltaX = screenX - offsetX; 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.x -= deltaX * camera.zoom;
camera.position.y -= deltaY * camera.zoom; camera.position.y -= deltaY * camera.zoom;
offsetX = screenX; offsetX = screenX;
offsetY = Gdx.graphics.getHeight() - screenY; offsetY = Gdx.graphics.getHeight() - 1 - screenY;
return false; return false;
} }

View File

@ -230,9 +230,16 @@ namespace Spine.Unity.Editor {
EditorApplication.hierarchyWindowItemOnGUI += HierarchyDragAndDrop; EditorApplication.hierarchyWindowItemOnGUI += HierarchyDragAndDrop;
// Hierarchy Icons // Hierarchy Icons
#if UNITY_2017_2_OR_NEWER
EditorApplication.playModeStateChanged -= HierarchyIconsOnPlaymodeStateChanged;
EditorApplication.playModeStateChanged += HierarchyIconsOnPlaymodeStateChanged;
HierarchyIconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
#else
EditorApplication.playmodeStateChanged -= HierarchyIconsOnPlaymodeStateChanged; EditorApplication.playmodeStateChanged -= HierarchyIconsOnPlaymodeStateChanged;
EditorApplication.playmodeStateChanged += HierarchyIconsOnPlaymodeStateChanged; EditorApplication.playmodeStateChanged += HierarchyIconsOnPlaymodeStateChanged;
HierarchyIconsOnPlaymodeStateChanged(); HierarchyIconsOnPlaymodeStateChanged();
#endif
initialized = true; 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); 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()) { if (EditorGUI.EndChangeCheck()) {
EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, showHierarchyIcons); EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, showHierarchyIcons);
#if UNITY_2017_2_OR_NEWER
HierarchyIconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
#else
HierarchyIconsOnPlaymodeStateChanged(); HierarchyIconsOnPlaymodeStateChanged();
#endif
} }
EditorGUILayout.Separator(); EditorGUILayout.Separator();
@ -496,7 +507,11 @@ namespace Spine.Unity.Editor {
#endregion #endregion
#region Hierarchy #region Hierarchy
#if UNITY_2017_2_OR_NEWER
static void HierarchyIconsOnPlaymodeStateChanged (PlayModeStateChange stateChange) {
#else
static void HierarchyIconsOnPlaymodeStateChanged () { static void HierarchyIconsOnPlaymodeStateChanged () {
#endif
skeletonRendererTable.Clear(); skeletonRendererTable.Clear();
skeletonUtilityBoneTable.Clear(); skeletonUtilityBoneTable.Clear();
boundingBoxFollowerTable.Clear(); boundingBoxFollowerTable.Clear();

View File

@ -113,37 +113,37 @@ namespace Spine.Unity.Modules.AttachmentTools {
#region Runtime RegionAttachments #region Runtime RegionAttachments
/// <summary> /// <summary>
/// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses a new AtlasPage with the Material provided./// </summary> /// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses a new AtlasPage with the Material provided./// </summary>
public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material) { public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material, float rotation = 0f) {
return sprite.ToRegionAttachment(material.ToSpineAtlasPage()); return sprite.ToRegionAttachment(material.ToSpineAtlasPage(), rotation);
} }
/// <summary> /// <summary>
/// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses the AtlasPage provided./// </summary> /// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses the AtlasPage provided./// </summary>
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 (sprite == null) throw new System.ArgumentNullException("sprite");
if (page == null) throw new System.ArgumentNullException("page"); if (page == null) throw new System.ArgumentNullException("page");
var region = sprite.ToAtlasRegion(page); var region = sprite.ToAtlasRegion(page);
var unitsPerPixel = 1f / sprite.pixelsPerUnit; var unitsPerPixel = 1f / sprite.pixelsPerUnit;
return region.ToRegionAttachment(sprite.name, unitsPerPixel); return region.ToRegionAttachment(sprite.name, unitsPerPixel, rotation);
} }
/// <summary> /// <summary>
/// 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"</summary> /// 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"</summary>
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 (sprite == null) throw new System.ArgumentNullException("sprite");
if (shader == null) throw new System.ArgumentNullException("shader"); if (shader == null) throw new System.ArgumentNullException("shader");
var region = sprite.ToAtlasRegionPMAClone(shader, textureFormat, mipmaps, materialPropertySource); var region = sprite.ToAtlasRegionPMAClone(shader, textureFormat, mipmaps, materialPropertySource);
var unitsPerPixel = 1f / sprite.pixelsPerUnit; 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) { 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); return sprite.ToRegionAttachmentPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource, rotation);
} }
/// <summary> /// <summary>
/// Creates a new RegionAttachment from a given AtlasRegion.</summary> /// Creates a new RegionAttachment from a given AtlasRegion.</summary>
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 (string.IsNullOrEmpty(attachmentName)) throw new System.ArgumentException("attachmentName can't be null or empty.", "attachmentName");
if (region == null) throw new System.ArgumentNullException("region"); if (region == null) throw new System.ArgumentNullException("region");
@ -162,14 +162,13 @@ namespace Spine.Unity.Modules.AttachmentTools {
attachment.Path = region.name; attachment.Path = region.name;
attachment.scaleX = 1; attachment.scaleX = 1;
attachment.scaleY = 1; attachment.scaleY = 1;
attachment.rotation = 0; attachment.rotation = rotation;
attachment.r = 1; attachment.r = 1;
attachment.g = 1; attachment.g = 1;
attachment.b = 1; attachment.b = 1;
attachment.a = 1; attachment.a = 1;
// pass OriginalWidth and OriginalHeight because UpdateOffset uses it in its calculation. // pass OriginalWidth and OriginalHeight because UpdateOffset uses it in its calculation.
attachment.width = attachment.regionOriginalWidth * scale; attachment.width = attachment.regionOriginalWidth * scale;
attachment.height = attachment.regionOriginalHeight * scale; attachment.height = attachment.regionOriginalHeight * scale;

View File

@ -344,8 +344,8 @@ VertexOutput vert(VertexInput input)
output.pos = calculateLocalPos(input.vertex); output.pos = calculateLocalPos(input.vertex);
output.color = calculateVertexColor(input.color); output.color = calculateVertexColor(input.color);
output.texcoord = float3(calculateTextureCoord(input.texcoord), 0); 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) #if defined(FIXED_NORMALS_BACKFACE_RENDERING) || defined(_RIM_LIGHTING)
float4 powWorld = calculateWorldPos(input.vertex); float4 powWorld = calculateWorldPos(input.vertex);
#endif #endif