Skip to content

Commit 6f08142

Browse files
committed
Beta 0.1.2 commit
1 parent 46875fd commit 6f08142

File tree

120 files changed

+2133
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2133
-0
lines changed

Assets/UnitySpineImporter.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/3DParty.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/3DParty/CurveExtension.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
namespace CurveExtended{
5+
6+
public static class CurveExtension {
7+
8+
public static void UpdateAllLinearTangents(this AnimationCurve curve){
9+
for (int i = 0; i < curve.keys.Length; i++) {
10+
UpdateTangentsFromMode(curve, i);
11+
}
12+
}
13+
14+
// UnityEditor.CurveUtility.cs (c) Unity Technologies
15+
public static void UpdateTangentsFromMode(AnimationCurve curve, int index)
16+
{
17+
if (index < 0 || index >= curve.length)
18+
return;
19+
Keyframe key = curve[index];
20+
if (KeyframeUtil.GetKeyTangentMode(key, 0) == TangentMode.Linear && index >= 1)
21+
{
22+
key.inTangent = CalculateLinearTangent(curve, index, index - 1);
23+
curve.MoveKey(index, key);
24+
}
25+
if (KeyframeUtil.GetKeyTangentMode(key, 1) == TangentMode.Linear && index + 1 < curve.length)
26+
{
27+
key.outTangent = CalculateLinearTangent(curve, index, index + 1);
28+
curve.MoveKey(index, key);
29+
}
30+
if (KeyframeUtil.GetKeyTangentMode(key, 0) != TangentMode.Smooth && KeyframeUtil.GetKeyTangentMode(key, 1) != TangentMode.Smooth)
31+
return;
32+
curve.SmoothTangents(index, 0.0f);
33+
}
34+
35+
// UnityEditor.CurveUtility.cs (c) Unity Technologies
36+
public static float CalculateLinearTangent(AnimationCurve curve, int index, int toIndex)
37+
{
38+
return (float) (((double) curve[index].value - (double) curve[toIndex].value) / ((double) curve[index].time - (double) curve[toIndex].time));
39+
}
40+
41+
}
42+
}

Assets/UnitySpineImporter/3DParty/CurveExtension/CurveExtension.cs.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using System.Reflection;
4+
using System;
5+
6+
namespace CurveExtended{
7+
public enum TangentMode
8+
{
9+
Editable = 0,
10+
Smooth = 1,
11+
Linear = 2,
12+
Stepped = Linear | Smooth,
13+
}
14+
15+
public enum TangentDirection
16+
{
17+
Left,
18+
Right
19+
}
20+
21+
22+
public class KeyframeUtil {
23+
24+
public static Keyframe GetNew( float time, float value, TangentMode leftAndRight){
25+
return GetNew(time, value, leftAndRight,leftAndRight);
26+
}
27+
28+
public static Keyframe GetNew(float time, float value, TangentMode left, TangentMode right){
29+
object boxed = new Keyframe(time,value); // cant use struct in reflection
30+
31+
SetKeyBroken(boxed, true);
32+
SetKeyTangentMode(boxed, 0, left);
33+
SetKeyTangentMode(boxed, 1, right);
34+
35+
Keyframe keyframe = (Keyframe)boxed;
36+
if (left == TangentMode.Stepped )
37+
keyframe.inTangent = float.PositiveInfinity;
38+
if (right == TangentMode.Stepped )
39+
keyframe.outTangent = float.PositiveInfinity;
40+
41+
return keyframe;
42+
}
43+
44+
45+
// UnityEditor.CurveUtility.cs (c) Unity Technologies
46+
public static void SetKeyTangentMode(object keyframe, int leftRight, TangentMode mode)
47+
{
48+
49+
Type t = typeof( UnityEngine.Keyframe );
50+
FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
51+
int tangentMode = (int)field.GetValue(keyframe);
52+
53+
if (leftRight == 0)
54+
{
55+
tangentMode &= -7;
56+
tangentMode |= (int) mode << 1;
57+
}
58+
else
59+
{
60+
tangentMode &= -25;
61+
tangentMode |= (int) mode << 3;
62+
}
63+
64+
field.SetValue(keyframe, tangentMode);
65+
if (GetKeyTangentMode(tangentMode, leftRight) == mode)
66+
return;
67+
Debug.Log("bug");
68+
}
69+
70+
// UnityEditor.CurveUtility.cs (c) Unity Technologies
71+
public static TangentMode GetKeyTangentMode(int tangentMode, int leftRight)
72+
{
73+
if (leftRight == 0)
74+
return (TangentMode) ((tangentMode & 6) >> 1);
75+
else
76+
return (TangentMode) ((tangentMode & 24) >> 3);
77+
}
78+
79+
// UnityEditor.CurveUtility.cs (c) Unity Technologies
80+
public static TangentMode GetKeyTangentMode(Keyframe keyframe, int leftRight)
81+
{
82+
Type t = typeof( UnityEngine.Keyframe );
83+
FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
84+
int tangentMode = (int)field.GetValue(keyframe);
85+
if (leftRight == 0)
86+
return (TangentMode) ((tangentMode & 6) >> 1);
87+
else
88+
return (TangentMode) ((tangentMode & 24) >> 3);
89+
}
90+
91+
92+
// UnityEditor.CurveUtility.cs (c) Unity Technologies
93+
public static void SetKeyBroken(object keyframe, bool broken)
94+
{
95+
Type t = typeof( UnityEngine.Keyframe );
96+
FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
97+
int tangentMode = (int)field.GetValue(keyframe);
98+
99+
if (broken)
100+
tangentMode |= 1;
101+
else
102+
tangentMode &= -2;
103+
field.SetValue(keyframe, tangentMode);
104+
}
105+
106+
}
107+
}

Assets/UnitySpineImporter/3DParty/CurveExtension/KeyframeUtil.cs.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/3DParty/LitJson.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>
25+
26+
Thank you for reading this notice. Following the tradition of other public
27+
domain projects, here's a blessing:
28+
29+
May you find forgiveness for yourself and forgive others.
30+
May you experience and share the gift of unconditional love.
31+
May you see light, wherever the illusion of darkness appears.

Assets/UnitySpineImporter/3DParty/LitJson/COPYING.meta

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

Assets/UnitySpineImporter/3DParty/LitJson/LitJson.dll.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/Scripts.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/Scripts/Editor.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/Scripts/Editor/Model.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/Scripts/Editor/Model/Spine.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Atlas.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
5+
namespace UnitySpineImporter{
6+
public class SpineAtlas {
7+
public string imageName;
8+
public string format;
9+
public string filter;
10+
public string repeat;
11+
public List<SpineSprite> sprites;
12+
}
13+
}

Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Atlas/SpineAtlas.cs.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
6+
namespace UnitySpineImporter{
7+
public class SpineMultiatlasCreationException: System.Exception{
8+
public SpineMultiatlasCreationException(string message):base(message)
9+
{
10+
}
11+
}
12+
13+
14+
public class SpineMultiatlas : List<SpineAtlas> {
15+
16+
public static SpineMultiatlas deserializeFromFile(string multiatlasFilePath){
17+
SpineMultiatlas multiAtlas = new SpineMultiatlas();
18+
if (!File.Exists(multiatlasFilePath))
19+
throw new SpineMultiatlasCreationException("provided file does not exists");
20+
using(StreamReader streamReader = new StreamReader(multiatlasFilePath)){
21+
string line;
22+
bool setMainProps = false;
23+
SpineAtlas spineAtlas = null;
24+
SpineSprite sprite = null;
25+
while((line = streamReader.ReadLine())!=null){
26+
if (line==""){
27+
setMainProps = true;
28+
} else {
29+
if (setMainProps){
30+
spineAtlas = new SpineAtlas();
31+
multiAtlas.Add(spineAtlas);
32+
spineAtlas.imageName = line;
33+
spineAtlas.format = streamReader.ReadLine();
34+
spineAtlas.filter = streamReader.ReadLine();
35+
spineAtlas.repeat = streamReader.ReadLine();
36+
spineAtlas.sprites = new List<SpineSprite>();
37+
setMainProps = false;
38+
} else {
39+
sprite = new SpineSprite();
40+
sprite.name = line;
41+
try{
42+
sprite.rotate = bool.Parse(streamReader.ReadLine().Split(':')[1]);
43+
sprite.xy = SpineUtil.lineToVector2(streamReader.ReadLine());
44+
sprite.size = SpineUtil.lineToVector2(streamReader.ReadLine());
45+
sprite.orig = SpineUtil.lineToVector2(streamReader.ReadLine());
46+
sprite.offset = SpineUtil.lineToVector2(streamReader.ReadLine());
47+
sprite.index = int.Parse(streamReader.ReadLine().Split(':')[1]);
48+
} catch (System.FormatException e) {
49+
throw new SpineMultiatlasCreationException("can't parse source file \n" + multiatlasFilePath +"\n"+e);
50+
}
51+
spineAtlas.sprites.Add(sprite);
52+
}
53+
}
54+
}
55+
}
56+
57+
if (multiAtlas.Count == 0)
58+
throw new SpineMultiatlasCreationException("don't have any atlases in provided file");
59+
return multiAtlas;
60+
}
61+
}
62+
}

Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Atlas/SpineMultialtas.cs.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
namespace UnitySpineImporter{
4+
public class SpineSprite {
5+
public string name;
6+
7+
public bool rotate;
8+
public Vector2 xy;
9+
public Vector2 size;
10+
public Vector2 orig;
11+
public Vector2 offset;
12+
public int index; // not used (http://esotericsoftware.com/forum/viewtopic.php?f=7&t=1933)
13+
}
14+
}

Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Atlas/SpineSprite.cs.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySpineImporter/Scripts/Editor/Model/Spine/Data.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)