diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ba03e..b0a1dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +##### 1.2.0 +* Add support for animation data providers +* Fix bug that caused sprite color to reset on every frame +* Use sortOrder instead of z coordinate for z-index +* Add ability to choose sorting layer + ##### 1.1.2 * Reduce garbage generation to 0 diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll b/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll index acfc878..4fe209e 100644 Binary files a/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll and b/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll differ diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb b/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb index a576eca..bbd8c8b 100644 Binary files a/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb and b/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb differ diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb.meta b/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb.meta index e1da063..b0e46c6 100644 --- a/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb.meta +++ b/SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 542bc1fe427c11847b9fabfcee2e449b -timeCreated: 1449899952 +timeCreated: 1451105209 licenseType: Free DefaultImporter: userData: diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviour.cs b/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviour.cs index 1bb945e..c617e59 100644 --- a/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviour.cs +++ b/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviour.cs @@ -22,6 +22,9 @@ public class ChildData [ExecuteInEditMode] public class SpriterDotNetBehaviour : MonoBehaviour { + [HideInInspector] + public string SortingLayer; + [HideInInspector] public ChildData ChildData; @@ -58,6 +61,8 @@ public void Update() #endif if (Animator == null) return; + + Animator.SortingLayer = SortingLayer; Animator.Step(Time.deltaTime * 1000.0f); if (UseNativeTags) diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviourEditor.cs b/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviourEditor.cs new file mode 100644 index 0000000..e453478 --- /dev/null +++ b/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviourEditor.cs @@ -0,0 +1,41 @@ +// Copyright (c) 2015 The original author or authors +// +// This software may be modified and distributed under the terms +// of the zlib license. See the LICENSE file for details. + +#if UNITY_EDITOR + +using System; +using System.Reflection; +using UnityEditor; +using UnityEditorInternal; + +namespace SpriterDotNetUnity +{ + [CustomEditor(typeof(SpriterDotNetBehaviour))] + public class SpriterDotNetBehaviourEditor : Editor + { + string[] GetSortingLayerNames() + { + Type internalEditorUtilityType = typeof(InternalEditorUtility); + PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic); + return (string[])sortingLayersProperty.GetValue(null, new object[0]); + } + + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + SpriterDotNetBehaviour sdnb = target as SpriterDotNetBehaviour; + + string[] layers = GetSortingLayerNames(); + int currentIndex = Array.IndexOf(layers, sdnb.SortingLayer); + if (currentIndex < 0) currentIndex = 0; + int choiceIndex = EditorGUILayout.Popup("Sorting Layer", currentIndex, layers); + sdnb.SortingLayer = layers[choiceIndex]; + EditorUtility.SetDirty(target); + } + } +} + +#endif \ No newline at end of file diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviourEditor.cs.meta b/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviourEditor.cs.meta new file mode 100644 index 0000000..51d8f42 --- /dev/null +++ b/SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterDotNetBehaviourEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bbabdaf8fd7c6504189931bb7d95a421 +timeCreated: 1451105707 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNet/UnitySpriterAnimator.cs b/SpriterDotNet.Unity/Assets/SpriterDotNet/UnitySpriterAnimator.cs index fabd532..054021a 100644 --- a/SpriterDotNet.Unity/Assets/SpriterDotNet/UnitySpriterAnimator.cs +++ b/SpriterDotNet.Unity/Assets/SpriterDotNet/UnitySpriterAnimator.cs @@ -11,6 +11,8 @@ namespace SpriterDotNetUnity { public class UnitySpriterAnimator : SpriterAnimator { + public string SortingLayer { get; set; } + private const float DefaultPPU = 100.0f; private const float DefaultPivot = 0.5f; @@ -79,12 +81,14 @@ protected override void ApplySpriteTransform(Sprite sprite, SpriterObject info) float deltaX = (spritePivotX - info.PivotX) * size.x * info.ScaleX; float deltaY = (spritePivotY - info.PivotY) * size.y * info.ScaleY; - renderer.color = new Color(1.0f, 1.0f, 1.0f, info.Alpha); + Color c = renderer.color; + renderer.color = new Color(c.r, c.g, c.b, info.Alpha); pivot.transform.localEulerAngles = new Vector3(0, 0, info.Angle); pivot.transform.localPosition = new Vector3(info.X / ppu, info.Y / ppu, 0); child.transform.localPosition = new Vector3(deltaX, deltaY, child.transform.localPosition.z); child.transform.localScale = new Vector3(info.ScaleX, info.ScaleY, 1); + renderer.sortingLayerName = SortingLayer; renderer.sortingOrder = index; ++index; diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/GreyGuyPlus.unity b/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/GreyGuyPlus.unity index 1e26dc2..7b3b7f4 100644 Binary files a/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/GreyGuyPlus.unity and b/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/GreyGuyPlus.unity differ diff --git a/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/Scml/GreyGuyPlus/Player.prefab b/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/Scml/GreyGuyPlus/Player.prefab index a798a53..9e92042 100644 Binary files a/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/Scml/GreyGuyPlus/Player.prefab and b/SpriterDotNet.Unity/Assets/SpriterDotNetExamples/Scml/GreyGuyPlus/Player.prefab differ diff --git a/SpriterDotNet.Unity/SpriterDotNet.Unity.Examples.unitypackage b/SpriterDotNet.Unity/SpriterDotNet.Unity.Examples.unitypackage index 70ed289..4527d00 100644 Binary files a/SpriterDotNet.Unity/SpriterDotNet.Unity.Examples.unitypackage and b/SpriterDotNet.Unity/SpriterDotNet.Unity.Examples.unitypackage differ diff --git a/SpriterDotNet.Unity/SpriterDotNet.Unity.unitypackage b/SpriterDotNet.Unity/SpriterDotNet.Unity.unitypackage index b935e76..110c1ca 100644 Binary files a/SpriterDotNet.Unity/SpriterDotNet.Unity.unitypackage and b/SpriterDotNet.Unity/SpriterDotNet.Unity.unitypackage differ