From 9583728d15dedfeeb1e96de5e6fe2ad6613eeaf5 Mon Sep 17 00:00:00 2001 From: Dario Seyb Date: Sun, 1 Jun 2014 22:46:11 +0200 Subject: [PATCH] -moved Utils classes into separate files --- .../Spriter2Unity/Editor/Spriter/BoneRef.cs | 2 +- .../Editor/Spriter/BoneTimelineKey.cs | 2 +- .../Spriter2Unity/Editor/Spriter/Entity.cs | 2 +- .../Spriter2Unity/Editor/Spriter/File.cs | 2 +- .../Spriter2Unity/Editor/Spriter/Folder.cs | 2 +- .../Spriter2Unity/Editor/Spriter/Key.cs | 2 +- .../Spriter2Unity/Editor/Spriter/KeyElem.cs | 6 +- .../Editor/Spriter/MainlineKey.cs | 2 +- .../Spriter2Unity/Editor/Spriter/ObjectRef.cs | 3 +- .../Editor/Spriter/ObjectType.cs | 2 +- .../Spriter2Unity/Editor/Spriter/Ref.cs | 2 +- .../Editor/Spriter/ScmlObject.cs | 2 +- .../Editor/Spriter/SpatialInfo.cs | 2 +- .../Editor/Spriter/SpatialTimelineKey.cs | 2 +- .../Editor/Spriter/SpriteTimelineKey.cs | 2 +- .../Editor/Spriter/SpriterAnimation.cs | 2 +- .../Spriter2Unity/Editor/Spriter/Timeline.cs | 2 +- .../Editor/Spriter/TimelineKey.cs | 26 ++- .../Editor/Unity/AnimationBuilder.cs | 2 +- .../Editor/Unity/AnimationCurveBuilder.cs | 2 +- .../Editor/Unity/CharacterMapBuilder.cs | 2 +- .../Editor/Unity/PrefabBuilder.cs | 2 +- .../Editor/Unity/ScmlPostProcessor.cs | 2 +- .../Spriter2Unity/Editor/Utils.meta | 5 + .../AnimationCurveUtils.cs} | 181 +----------------- .../AnimationCurveUtils.cs.meta} | 2 +- .../Spriter2Unity/Editor/Utils/PrefabUtils.cs | 73 +++++++ .../Editor/Utils/PrefabUtils.cs.meta | 8 + .../Spriter2Unity/Editor/Utils/XmlUtils.cs | 150 +++++++++++++++ .../Editor/Utils/XmlUtils.cs.meta | 8 + .../Spriter2Unity/Scripts/CharacterMap.cs | 2 +- ProjectSettings/EditorSettings.asset | Bin 4184 -> 4184 bytes 32 files changed, 293 insertions(+), 211 deletions(-) create mode 100644 Assets/ThirdParty/Spriter2Unity/Editor/Utils.meta rename Assets/ThirdParty/Spriter2Unity/Editor/{Utils.cs => Utils/AnimationCurveUtils.cs} (59%) rename Assets/ThirdParty/Spriter2Unity/Editor/{Utils.cs.meta => Utils/AnimationCurveUtils.cs.meta} (78%) create mode 100644 Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs create mode 100644 Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs.meta create mode 100644 Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs create mode 100644 Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs.meta diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneRef.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneRef.cs index 5f6e3dc..30beefa 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneRef.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneRef.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneTimelineKey.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneTimelineKey.cs index 817c4a4..59f0ad5 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneTimelineKey.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/BoneTimelineKey.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Entity.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Entity.cs index 6928d94..857b0c9 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Entity.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Entity.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/File.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/File.cs index e04d8f6..1e86f37 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/File.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/File.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Folder.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Folder.cs index ad26dc3..7712054 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Folder.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Folder.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Key.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Key.cs index 30ca203..14b09af 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Key.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Key.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/KeyElem.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/KeyElem.cs index 6647d9f..9fbd5d4 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/KeyElem.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/KeyElem.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy @@ -20,10 +20,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Xml; namespace Assets.ThirdParty.Spriter2Unity.Editor.Spriter diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/MainlineKey.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/MainlineKey.cs index c4e832a..078c29a 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/MainlineKey.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/MainlineKey.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectRef.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectRef.cs index 2efba94..a486fe8 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectRef.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectRef.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy @@ -20,6 +20,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + using System; using System.Collections.Generic; using System.Linq; diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectType.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectType.cs index 85967d3..9c0d6d9 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectType.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ObjectType.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Ref.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Ref.cs index bfbbc83..de14096 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Ref.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Ref.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ScmlObject.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ScmlObject.cs index 18b2e70..a1c81b4 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ScmlObject.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/ScmlObject.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialInfo.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialInfo.cs index 7bb6e77..e673340 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialInfo.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialInfo.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialTimelineKey.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialTimelineKey.cs index bb199d4..1c6b67b 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialTimelineKey.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpatialTimelineKey.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriteTimelineKey.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriteTimelineKey.cs index b8e38d0..db0a7b8 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriteTimelineKey.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriteTimelineKey.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriterAnimation.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriterAnimation.cs index 09925a9..2dfe073 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriterAnimation.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/SpriterAnimation.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Timeline.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Timeline.cs index f41767c..1728a76 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Timeline.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/Timeline.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/TimelineKey.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/TimelineKey.cs index b68539d..0e8698c 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/TimelineKey.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Spriter/TimelineKey.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy @@ -20,6 +20,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + using System; using System.Collections.Generic; using System.Linq; @@ -28,10 +29,24 @@ THE SOFTWARE. namespace Assets.ThirdParty.Spriter2Unity.Editor.Spriter { + /// + /// Base class for all timeline keys. + /// public class TimelineKey : Key { + /// + /// Reference to the timeline the key is on. + /// public Timeline Timeline { get; private set; } + + /// + /// The interpolation type to use for this key. + /// public CurveType CurveType { get; private set; } + + /// + /// Parameters to use for interpolation (quadratic and qubic at the moment) + /// public float[] CurveParams { get; private set; } public TimelineKey(XmlElement element, Timeline timeline) @@ -85,15 +100,6 @@ void GetCurveParams(XmlElement element) CurveParams = curveParams .Select(attr => float.Parse(attr.Value)) .ToArray(); - /* - //Debug Output - consider using #ifdef instead - if(curveParams.Count > 0) - { - var curveParamString = curveParams.OfType() - .Select(attr => "\"" + attr.Name + "\":" + attr.Value) - .Aggregate((current,next)=> current + ";" + next); - UnityEngine.Debug.Log(string.Format("Found {0} curve parameters on timeline {1}, key {2} curvetype {3} ({4})", curveParams.Count, Timeline.Name, Id, CurveType, curveParamString)); - }*/ } } } diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationBuilder.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationBuilder.cs index a3b514b..aec7197 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationBuilder.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationBuilder.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationCurveBuilder.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationCurveBuilder.cs index 018c36d..c99e337 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationCurveBuilder.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/AnimationCurveBuilder.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/CharacterMapBuilder.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/CharacterMapBuilder.cs index dfbbfc6..98f26ff 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/CharacterMapBuilder.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/CharacterMapBuilder.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/PrefabBuilder.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/PrefabBuilder.cs index 24e96f2..1301e3d 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/PrefabBuilder.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/PrefabBuilder.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/ScmlPostProcessor.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/ScmlPostProcessor.cs index 56c8b5d..18de42c 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Unity/ScmlPostProcessor.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Unity/ScmlPostProcessor.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils.meta b/Assets/ThirdParty/Spriter2Unity/Editor/Utils.meta new file mode 100644 index 0000000..6991e01 --- /dev/null +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 3aa93cf1a1fa82c4ca6a5982f0c52a3c +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/AnimationCurveUtils.cs similarity index 59% rename from Assets/ThirdParty/Spriter2Unity/Editor/Utils.cs rename to Assets/ThirdParty/Spriter2Unity/Editor/Utils/AnimationCurveUtils.cs index 04f03d6..5cb69a1 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Utils.cs +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/AnimationCurveUtils.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy @@ -20,180 +20,14 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -using UnityEngine; -using System.Collections; -using System.Xml; -using UnityEditor; + using Assets.ThirdParty.Spriter2Unity.Editor.Spriter; using System.Reflection; +using UnityEditor; +using UnityEngine; -namespace Assets.ThirdParty.Spriter2Unity.Editor +namespace Assets.ThirdParty.Spriter2Unity.Editor.Spriter { - public static class PrefabUtils - { - public static float PixelScale = 0.01f; - public static float ZSpacing = 0.1f; - - public static void BakeTransforms(this Ref childRef, out Vector3 localPosition, out Vector3 localEulerAngles, out Vector3 localScale) - { - TimelineKey key = childRef.Referenced; - - localPosition = Vector3.zero; - localScale = Vector3.one; - localEulerAngles = Vector3.zero; - - var unmapped = childRef.Unmapped; - var spatial = childRef.Referenced as SpatialTimelineKey; - if (spatial != null) - { - localPosition = unmapped.Position; - - var spriteKey = key as SpriteTimelineKey; - if (spriteKey != null) - { - var sinA = Mathf.Sin(unmapped.Angle); - var cosA = Mathf.Cos(unmapped.Angle); - - var pvt = spriteKey.GetPivotOffetFromMiddle(); - - pvt.x *= unmapped.Scale.x; - pvt.y *= unmapped.Scale.y; - - var rotPX = pvt.x * cosA - pvt.y * sinA; - var rotPY = pvt.x * sinA + pvt.y * cosA; - - localPosition.x += rotPX; - localPosition.y += rotPY; - - localScale.x = unmapped.Scale.x; - localScale.y = unmapped.Scale.y; - localPosition.z = ((ObjectRef)childRef).ZIndex * -ZSpacing; - } - localPosition *= PixelScale; - localEulerAngles = new Vector3(0, 0, unmapped.Angle_Deg); - } - } - } - public static class XmlUtils - { - public static bool TryGetString(this XmlNode node, string key, out string value) - { - value = default(string); - var attr = node.Attributes[key]; - bool parsed = false; - if (attr != null) - { - parsed = true; - value = attr.Value; - } - - return parsed; - } - - public static bool TryGetInt(this XmlNode node, string key, out int value) - { - value = default(int); - var attr = node.Attributes[key]; - bool parsed = false; - if (attr != null) - { - parsed = int.TryParse(attr.Value, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out value); - } - - return parsed; - } - - public static bool TryGetFloat(this XmlNode node, string key, out float value) - { - value = default(float); - var attr = node.Attributes[key]; - bool parsed = false; - if (attr != null) - { - parsed = float.TryParse(attr.Value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out value); - } - - return parsed; - } - - public static bool TryGetVector2(this XmlNode node, out Vector2 value) - { - value = default(Vector2); - float tmp; - bool parsed = true; - if (TryGetFloat(node, "x", out tmp)) value.x = tmp; - else parsed = false; - if (TryGetFloat(node, "y", out tmp)) value.y = tmp; - else parsed = false; - - return parsed; - } - - public static bool TryGetVector3(this XmlNode node, out Vector3 value) - { - value = default(Vector3); - float tmp; - bool parsed = true; - if (TryGetFloat(node, "x", out tmp)) value.x = tmp; - else parsed = false; - if (TryGetFloat(node, "y", out tmp)) value.y = tmp; - else parsed = false; - if (TryGetFloat(node, "z", out tmp)) value.z = tmp; - else parsed = false; - - return parsed; - } - - public static string GetString(this XmlNode node, string key, string defaultVal) - { - string value = defaultVal; - var attr = node.Attributes[key]; - if (attr != null) - { - value = attr.Value; - } - return value; - } - - public static int GetInt(this XmlNode node, string key, int defaultVal) - { - int value = defaultVal; - int tmp; - if (TryGetInt(node, key, out tmp)) value = tmp; - - return value; - } - - public static float GetFloat(this XmlNode node, string key, float defaultVal) - { - var value = defaultVal; - float tmp; - if (TryGetFloat(node, key, out tmp)) value = tmp; - - return value; - } - - public static Vector2 GetVector2(this XmlNode node, Vector2 defaultVal) - { - var value = defaultVal; - float tmp; - if (TryGetFloat(node, "x", out tmp)) value.x = tmp; - if (TryGetFloat(node, "y", out tmp)) value.y = tmp; - - return value; - } - - public static Vector3 GetVector3(this XmlNode node) - { - var value = default(Vector3); - float tmp; - if (TryGetFloat(node, "x", out tmp)) value.x = tmp; - if (TryGetFloat(node, "y", out tmp)) value.y = tmp; - if (TryGetFloat(node, "z", out tmp)) value.z = tmp; - - return value; - } - } public static class AnimationCurveUtils { public const float MIN_DELTA_TIME = 0.001f; @@ -208,7 +42,7 @@ public static void AddKey(this AnimationCurve curve, Keyframe keyframe, Timeline return; } - if(lastKey == null) + if (lastKey == null) { Debug.Log(string.Format("ERROR: NULL lastkey passed to AddKey when curve contains {0} keys", keys.Length)); return; @@ -358,4 +192,5 @@ public static void SetAnimationSettings(this AnimationClip animClip, AnimationCl mInfo.Invoke(null, new object[] { animClip, settings }); } } -} \ No newline at end of file +} + diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils.cs.meta b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/AnimationCurveUtils.cs.meta similarity index 78% rename from Assets/ThirdParty/Spriter2Unity/Editor/Utils.cs.meta rename to Assets/ThirdParty/Spriter2Unity/Editor/Utils/AnimationCurveUtils.cs.meta index 8e33b73..a8b549c 100644 --- a/Assets/ThirdParty/Spriter2Unity/Editor/Utils.cs.meta +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/AnimationCurveUtils.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 611fe5609a46f924ea5826b43c510635 +guid: f3d336ec56d57a645b32082f9c0a6f36 MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs new file mode 100644 index 0000000..f5c3b89 --- /dev/null +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs @@ -0,0 +1,73 @@ +/* +Copyright (c) 2014 Andrew Jones, Dario Seyb + Based on 'Spriter2Unity' python code by Malhavok + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using UnityEngine; + +namespace Assets.ThirdParty.Spriter2Unity.Editor.Spriter +{ + public static class PrefabUtils + { + public const float PIXEL_SCALE = 0.01f; + public const float Z_SPACING = 0.1f; + + public static void BakeTransforms(this Ref childRef, out Vector3 localPosition, out Vector3 localEulerAngles, out Vector3 localScale) + { + TimelineKey key = childRef.Referenced; + + localPosition = Vector3.zero; + localScale = Vector3.one; + localEulerAngles = Vector3.zero; + + var unmapped = childRef.Unmapped; + var spatial = childRef.Referenced as SpatialTimelineKey; + if (spatial != null) + { + localPosition = unmapped.Position; + + var spriteKey = key as SpriteTimelineKey; + if (spriteKey != null) + { + var sinA = Mathf.Sin(unmapped.Angle); + var cosA = Mathf.Cos(unmapped.Angle); + + var pvt = spriteKey.GetPivotOffetFromMiddle(); + + pvt.x *= unmapped.Scale.x; + pvt.y *= unmapped.Scale.y; + + var rotPX = pvt.x * cosA - pvt.y * sinA; + var rotPY = pvt.x * sinA + pvt.y * cosA; + + localPosition.x += rotPX; + localPosition.y += rotPY; + + localScale.x = unmapped.Scale.x; + localScale.y = unmapped.Scale.y; + localPosition.z = ((ObjectRef)childRef).ZIndex * -Z_SPACING; + } + localPosition *= PIXEL_SCALE; + localEulerAngles = new Vector3(0, 0, unmapped.Angle_Deg); + } + } + } +} \ No newline at end of file diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs.meta b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs.meta new file mode 100644 index 0000000..ffc9317 --- /dev/null +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/PrefabUtils.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1dcb73550959f6e4baa0fa74a3dbb879 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs new file mode 100644 index 0000000..8d4c225 --- /dev/null +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs @@ -0,0 +1,150 @@ +/* +Copyright (c) 2014 Andrew Jones, Dario Seyb + Based on 'Spriter2Unity' python code by Malhavok + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using System.Xml; +using UnityEngine; + +namespace Assets.ThirdParty.Spriter2Unity.Editor.Spriter +{ + public static class XmlUtils + { + public static bool TryGetString(this XmlNode node, string key, out string value) + { + value = default(string); + var attr = node.Attributes[key]; + bool parsed = false; + if (attr != null) + { + parsed = true; + value = attr.Value; + } + + return parsed; + } + + public static bool TryGetInt(this XmlNode node, string key, out int value) + { + value = default(int); + var attr = node.Attributes[key]; + bool parsed = false; + if (attr != null) + { + parsed = int.TryParse(attr.Value, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out value); + } + + return parsed; + } + + public static bool TryGetFloat(this XmlNode node, string key, out float value) + { + value = default(float); + var attr = node.Attributes[key]; + bool parsed = false; + if (attr != null) + { + parsed = float.TryParse(attr.Value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out value); + } + + return parsed; + } + + public static bool TryGetVector2(this XmlNode node, out Vector2 value) + { + value = default(Vector2); + float tmp; + bool parsed = true; + if (TryGetFloat(node, "x", out tmp)) value.x = tmp; + else parsed = false; + if (TryGetFloat(node, "y", out tmp)) value.y = tmp; + else parsed = false; + + return parsed; + } + + public static bool TryGetVector3(this XmlNode node, out Vector3 value) + { + value = default(Vector3); + float tmp; + bool parsed = true; + if (TryGetFloat(node, "x", out tmp)) value.x = tmp; + else parsed = false; + if (TryGetFloat(node, "y", out tmp)) value.y = tmp; + else parsed = false; + if (TryGetFloat(node, "z", out tmp)) value.z = tmp; + else parsed = false; + + return parsed; + } + + public static string GetString(this XmlNode node, string key, string defaultVal) + { + string value = defaultVal; + var attr = node.Attributes[key]; + if (attr != null) + { + value = attr.Value; + } + return value; + } + + public static int GetInt(this XmlNode node, string key, int defaultVal) + { + int value = defaultVal; + int tmp; + if (TryGetInt(node, key, out tmp)) value = tmp; + + return value; + } + + public static float GetFloat(this XmlNode node, string key, float defaultVal) + { + var value = defaultVal; + float tmp; + if (TryGetFloat(node, key, out tmp)) value = tmp; + + return value; + } + + public static Vector2 GetVector2(this XmlNode node, Vector2 defaultVal) + { + var value = defaultVal; + float tmp; + if (TryGetFloat(node, "x", out tmp)) value.x = tmp; + if (TryGetFloat(node, "y", out tmp)) value.y = tmp; + + return value; + } + + public static Vector3 GetVector3(this XmlNode node) + { + var value = default(Vector3); + float tmp; + if (TryGetFloat(node, "x", out tmp)) value.x = tmp; + if (TryGetFloat(node, "y", out tmp)) value.y = tmp; + if (TryGetFloat(node, "z", out tmp)) value.z = tmp; + + return value; + } + } +} + diff --git a/Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs.meta b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs.meta new file mode 100644 index 0000000..ed0ea2a --- /dev/null +++ b/Assets/ThirdParty/Spriter2Unity/Editor/Utils/XmlUtils.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d1783dfcc18336d4e9b76bb114bbc898 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/ThirdParty/Spriter2Unity/Scripts/CharacterMap.cs b/Assets/ThirdParty/Spriter2Unity/Scripts/CharacterMap.cs index f0dbd93..4f878e4 100644 --- a/Assets/ThirdParty/Spriter2Unity/Scripts/CharacterMap.cs +++ b/Assets/ThirdParty/Spriter2Unity/Scripts/CharacterMap.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014 Andrew Jones +Copyright (c) 2014 Andrew Jones, Dario Seyb Based on 'Spriter2Unity' python code by Malhavok Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset index 001a1cc34df7e6b155c53650757d22db76524e20..dc7524e012b7ee99fa3d9b338a4fbcebb69a5172 100644 GIT binary patch delta 16 Wcmcbia6@53fB*+00|NsS5CZ@yhyx4& delta 16 Scmcbia6@53fB**r6aWAzcmoLl