Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
loodakrawa committed Dec 26, 2015
1 parent 10a0913 commit a9ecb1c
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Binary file modified SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll
Binary file not shown.
Binary file modified SpriterDotNet.Unity/Assets/SpriterDotNet/Lib/SpriterDotNet.dll.mdb
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class ChildData
[ExecuteInEditMode]
public class SpriterDotNetBehaviour : MonoBehaviour
{
[HideInInspector]
public string SortingLayer;

[HideInInspector]
public ChildData ChildData;

Expand Down Expand Up @@ -58,6 +61,8 @@ public void Update()
#endif

if (Animator == null) return;

Animator.SortingLayer = SortingLayer;
Animator.Step(Time.deltaTime * 1000.0f);

if (UseNativeTags)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace SpriterDotNetUnity
{
public class UnitySpriterAnimator : SpriterAnimator<Sprite, AudioClip>
{
public string SortingLayer { get; set; }

private const float DefaultPPU = 100.0f;
private const float DefaultPivot = 0.5f;

Expand Down Expand Up @@ -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;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified SpriterDotNet.Unity/SpriterDotNet.Unity.Examples.unitypackage
Binary file not shown.
Binary file modified SpriterDotNet.Unity/SpriterDotNet.Unity.unitypackage
Binary file not shown.

0 comments on commit a9ecb1c

Please sign in to comment.