diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 8144543cc..23f1eff7f 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -442,7 +442,7 @@ namespace Spine { /// The maximum number of Bezier curves. See . /// Unique identifiers for the properties the timeline modifies. public CurveTimeline2 (int frameCount, int bezierCount, string propertyId1, string propertyId2) - :base (frameCount, bezierCount, propertyId1, propertyId2) { + : base(frameCount, bezierCount, propertyId1, propertyId2) { } public override int FrameEntries { @@ -515,7 +515,7 @@ namespace Spine { public TranslateTimeline (int frameCount, int bezierCount, int boneIndex) : base(frameCount, bezierCount, // (int)Property.X + "|" + boneIndex, // - (int) Property.Y + "|" + boneIndex) { + (int)Property.Y + "|" + boneIndex) { this.boneIndex = boneIndex; } @@ -2077,7 +2077,7 @@ namespace Spine { /// Between 0 and frameCount, inclusive. public void SetFrame (int frame, Event e) { frames[frame] = e.time; - events [frame] = e; + events[frame] = e; } /// Fires events for frames > lastTime and <= time. @@ -2411,7 +2411,7 @@ namespace Spine { readonly int pathConstraintIndex; public PathConstraintPositionTimeline (int frameCount, int bezierCount, int pathConstraintIndex) - :base(frameCount, bezierCount, (int)Property.PathConstraintPosition + "|" + pathConstraintIndex) { + : base(frameCount, bezierCount, (int)Property.PathConstraintPosition + "|" + pathConstraintIndex) { this.pathConstraintIndex = pathConstraintIndex; } diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 7ce9544cc..0da0475e5 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -73,7 +73,7 @@ namespace Spine { /// out position. internal const int HoldMix = 4; - internal const int Setup = 1, Current = 2; + internal const int Setup = 1, Current = 2; protected AnimationStateData data; private readonly ExposedList tracks = new ExposedList(); @@ -510,15 +510,15 @@ namespace Spine { float r1, r2; if (time < frames[0]) { // Time is before first frame. switch (blend) { - case MixBlend.Setup: - bone.rotation = bone.data.rotation; - goto default; // Fall through. - default: - return; - case MixBlend.First: - r1 = bone.rotation; - r2 = bone.data.rotation; - break; + case MixBlend.Setup: + bone.rotation = bone.data.rotation; + goto default; // Fall through. + default: + return; + case MixBlend.First: + r1 = bone.rotation; + r2 = bone.data.rotation; + break; } } else { r1 = blend == MixBlend.Setup ? bone.data.rotation : bone.rotation; @@ -590,7 +590,7 @@ namespace Spine { /// /// It may be desired to use to mix the skeletons back to the setup pose, /// rather than leaving them in their current pose. - /// + /// public void ClearTracks () { bool oldDrainDisabled = queue.drainDisabled; queue.drainDisabled = true; @@ -896,7 +896,7 @@ namespace Spine { } timelineMode[i] = AnimationState.HoldFirst; } - continue_outer: {} + continue_outer: { } } } diff --git a/spine-csharp/src/Atlas.cs b/spine-csharp/src/Atlas.cs index 56f4dc58b..347ffbd07 100644 --- a/spine-csharp/src/Atlas.cs +++ b/spine-csharp/src/Atlas.cs @@ -261,7 +261,7 @@ namespace Spine { int colon = line.IndexOf(':'); if (colon == -1) return 0; entry[0] = line.Substring(0, colon).Trim(); - for (int i = 1, lastMatch = colon + 1;; i++) { + for (int i = 1, lastMatch = colon + 1; ; i++) { int comma = line.IndexOf(',', lastMatch); if (comma == -1) { entry[i] = line.Substring(lastMatch).Trim(); diff --git a/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs b/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs index 8dc263196..3cf20a53b 100644 --- a/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs +++ b/spine-csharp/src/Attachments/AtlasAttachmentLoader.cs @@ -89,7 +89,7 @@ namespace Spine { return new PointAttachment(name); } - public ClippingAttachment NewClippingAttachment(Skin skin, string name) { + public ClippingAttachment NewClippingAttachment (Skin skin, string name) { return new ClippingAttachment(name); } diff --git a/spine-csharp/src/Attachments/ClippingAttachment.cs b/spine-csharp/src/Attachments/ClippingAttachment.cs index b0aa8db61..039f9bc22 100644 --- a/spine-csharp/src/Attachments/ClippingAttachment.cs +++ b/spine-csharp/src/Attachments/ClippingAttachment.cs @@ -35,7 +35,7 @@ namespace Spine { public SlotData EndSlot { get { return endSlot; } set { endSlot = value; } } - public ClippingAttachment(string name) : base(name) { + public ClippingAttachment (string name) : base(name) { } public override Attachment Copy () { diff --git a/spine-csharp/src/Attachments/MeshAttachment.cs b/spine-csharp/src/Attachments/MeshAttachment.cs index 12603915d..88ec38c6b 100644 --- a/spine-csharp/src/Attachments/MeshAttachment.cs +++ b/spine-csharp/src/Attachments/MeshAttachment.cs @@ -129,7 +129,7 @@ namespace Spine { width = RegionOriginalHeight / textureWidth; height = RegionOriginalWidth / textureHeight; - for (int i = 0, n = uvs.Length; iThe base class for all constraint datas. public abstract class ConstraintData { internal readonly string name; diff --git a/spine-csharp/src/ExposedList.cs b/spine-csharp/src/ExposedList.cs index 07cde4a9a..6bcd610fe 100644 --- a/spine-csharp/src/ExposedList.cs +++ b/spine-csharp/src/ExposedList.cs @@ -298,7 +298,7 @@ namespace Spine { private int GetLastIndex (int startIndex, int count, Predicate match) { // unlike FindLastIndex, takes regular params for search range - for (int i = startIndex + count; i != startIndex; ) + for (int i = startIndex + count; i != startIndex;) if (match(Items[--i])) return i; return -1; diff --git a/spine-csharp/src/IkConstraint.cs b/spine-csharp/src/IkConstraint.cs index 4018ee423..1bcdfab11 100644 --- a/spine-csharp/src/IkConstraint.cs +++ b/spine-csharp/src/IkConstraint.cs @@ -166,27 +166,27 @@ namespace Spine { float rotationIK = -bone.ashearX - bone.arotation; float tx = 0, ty = 0; - switch(bone.data.transformMode) { - case TransformMode.OnlyTranslation: - tx = targetX - bone.worldX; - ty = targetY - bone.worldY; - break; - case TransformMode.NoRotationOrReflection: { - float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc); - float sa = pa / bone.skeleton.ScaleX; - float sc = pc / bone.skeleton.ScaleY; - pb = -sc * s * bone.skeleton.ScaleX; - pd = sa * s * bone.skeleton.ScaleY; - rotationIK += (float)Math.Atan2(sc, sa) * MathUtils.RadDeg; - goto default; // Fall through. - } - default: { - float x = targetX - p.worldX, y = targetY - p.worldY; - float d = pa * pd - pb * pc; - tx = (x * pd - y * pb) / d - bone.ax; - ty = (y * pa - x * pc) / d - bone.ay; - break; - } + switch (bone.data.transformMode) { + case TransformMode.OnlyTranslation: + tx = targetX - bone.worldX; + ty = targetY - bone.worldY; + break; + case TransformMode.NoRotationOrReflection: { + float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc); + float sa = pa / bone.skeleton.ScaleX; + float sc = pc / bone.skeleton.ScaleY; + pb = -sc * s * bone.skeleton.ScaleX; + pd = sa * s * bone.skeleton.ScaleY; + rotationIK += (float)Math.Atan2(sc, sa) * MathUtils.RadDeg; + goto default; // Fall through. + } + default: { + float x = targetX - p.worldX, y = targetY - p.worldY; + float d = pa * pd - pb * pc; + tx = (x * pd - y * pb) / d - bone.ax; + ty = (y * pa - x * pc) / d - bone.ay; + break; + } } rotationIK += (float)Math.Atan2(ty, tx) * MathUtils.RadDeg; @@ -199,11 +199,11 @@ namespace Spine { float sx = bone.ascaleX, sy = bone.ascaleY; if (compress || stretch) { switch (bone.data.transformMode) { - case TransformMode.NoScale: - case TransformMode.NoScaleOrReflection: - tx = targetX - bone.worldX; - ty = targetY - bone.worldY; - break; + case TransformMode.NoScale: + case TransformMode.NoScaleOrReflection: + tx = targetX - bone.worldX; + ty = targetY - bone.worldY; + break; } float b = bone.data.length * sx, dd = (float)Math.Sqrt(tx * tx + ty * ty); if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001f) { diff --git a/spine-csharp/src/Json.cs b/spine-csharp/src/Json.cs index aa790f422..fbb263843 100644 --- a/spine-csharp/src/Json.cs +++ b/spine-csharp/src/Json.cs @@ -28,11 +28,11 @@ *****************************************************************************/ using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text; -using System.Collections; -using System.Globalization; -using System.Collections.Generic; namespace Spine { public static class Json { @@ -70,10 +70,8 @@ namespace Spine { * 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. */ -namespace SharpJson -{ - class Lexer - { +namespace SharpJson { + class Lexer { public enum Token { None, Null, @@ -110,23 +108,20 @@ namespace SharpJson bool success = true; char[] stringBuffer = new char[4096]; - public Lexer(string text) - { + public Lexer (string text) { Reset(); json = text.ToCharArray(); parseNumbersAsFloat = false; } - public void Reset() - { + public void Reset () { index = 0; lineNumber = 1; success = true; } - public string ParseString() - { + public string ParseString () { int idx = 0; StringBuilder builder = null; @@ -165,8 +160,8 @@ namespace SharpJson case 'b': stringBuffer[idx++] = '\b'; break; - case'f': - stringBuffer[idx++] = '\f'; + case 'f': + stringBuffer[idx++] = '\f'; break; case 'n': stringBuffer[idx++] = '\n'; @@ -183,7 +178,7 @@ namespace SharpJson var hex = new string(json, index, 4); // XXX: handle UTF - stringBuffer[idx++] = (char) Convert.ToInt32(hex, 16); + stringBuffer[idx++] = (char)Convert.ToInt32(hex, 16); // skip 4 chars index += 4; @@ -211,40 +206,37 @@ namespace SharpJson } if (builder != null) - return builder.ToString (); + return builder.ToString(); else - return new string (stringBuffer, 0, idx); + return new string(stringBuffer, 0, idx); } - string GetNumberString() - { + string GetNumberString () { SkipWhiteSpaces(); int lastIndex = GetLastIndexOfNumber(index); int charLength = (lastIndex - index) + 1; - var result = new string (json, index, charLength); + var result = new string(json, index, charLength); index = lastIndex + 1; return result; } - public float ParseFloatNumber() - { + public float ParseFloatNumber () { float number; - var str = GetNumberString (); + var str = GetNumberString(); - if (!float.TryParse (str, NumberStyles.Float, CultureInfo.InvariantCulture, out number)) + if (!float.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out number)) return 0; return number; } - public double ParseDoubleNumber() - { + public double ParseDoubleNumber () { double number; - var str = GetNumberString (); + var str = GetNumberString(); if (!double.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) return 0; @@ -252,23 +244,21 @@ namespace SharpJson return number; } - int GetLastIndexOfNumber(int index) - { + int GetLastIndexOfNumber (int index) { int lastIndex; for (lastIndex = index; lastIndex < json.Length; lastIndex++) { char ch = json[lastIndex]; if ((ch < '0' || ch > '9') && ch != '+' && ch != '-' - && ch != '.' && ch != 'e' && ch != 'E') + && ch != '.' && ch != 'e' && ch != 'E') break; } return lastIndex - 1; } - void SkipWhiteSpaces() - { + void SkipWhiteSpaces () { for (; index < json.Length; index++) { char ch = json[index]; @@ -280,22 +270,19 @@ namespace SharpJson } } - public Token LookAhead() - { + public Token LookAhead () { SkipWhiteSpaces(); int savedIndex = index; return NextToken(json, ref savedIndex); } - public Token NextToken() - { + public Token NextToken () { SkipWhiteSpaces(); return NextToken(json, ref index); } - static Token NextToken(char[] json, ref int index) - { + static Token NextToken (char[] json, ref int index) { if (index == json.Length) return Token.None; @@ -314,8 +301,16 @@ namespace SharpJson return Token.Comma; case '"': return Token.String; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': case '-': return Token.Number; case ':': @@ -329,10 +324,10 @@ namespace SharpJson // false if (remainingLength >= 5) { if (json[index] == 'f' && - json[index + 1] == 'a' && - json[index + 2] == 'l' && - json[index + 3] == 's' && - json[index + 4] == 'e') { + json[index + 1] == 'a' && + json[index + 2] == 'l' && + json[index + 3] == 's' && + json[index + 4] == 'e') { index += 5; return Token.False; } @@ -341,9 +336,9 @@ namespace SharpJson // true if (remainingLength >= 4) { if (json[index] == 't' && - json[index + 1] == 'r' && - json[index + 2] == 'u' && - json[index + 3] == 'e') { + json[index + 1] == 'r' && + json[index + 2] == 'u' && + json[index + 3] == 'e') { index += 4; return Token.True; } @@ -352,9 +347,9 @@ namespace SharpJson // null if (remainingLength >= 4) { if (json[index] == 'n' && - json[index + 1] == 'u' && - json[index + 2] == 'l' && - json[index + 3] == 'l') { + json[index + 1] == 'u' && + json[index + 2] == 'l' && + json[index + 3] == 'l') { index += 4; return Token.Null; } @@ -364,8 +359,7 @@ namespace SharpJson } } - public class JsonDecoder - { + public class JsonDecoder { public string errorMessage { get; private set; @@ -378,14 +372,12 @@ namespace SharpJson Lexer lexer; - public JsonDecoder() - { + public JsonDecoder () { errorMessage = null; parseNumbersAsFloat = false; } - public object Decode(string text) - { + public object Decode (string text) { errorMessage = null; lexer = new Lexer(text); @@ -394,14 +386,12 @@ namespace SharpJson return ParseValue(); } - public static object DecodeText(string text) - { + public static object DecodeText (string text) { var builder = new JsonDecoder(); return builder.Decode(text); } - IDictionary ParseObject() - { + IDictionary ParseObject () { var table = new Dictionary(); // { @@ -449,8 +439,7 @@ namespace SharpJson //return null; // Unreachable code } - IList ParseArray() - { + IList ParseArray () { var array = new List(); // [ @@ -483,8 +472,7 @@ namespace SharpJson //return null; // Unreachable code } - object ParseValue() - { + object ParseValue () { switch (lexer.LookAhead()) { case Lexer.Token.String: return EvalLexer(lexer.ParseString()); @@ -514,14 +502,12 @@ namespace SharpJson return null; } - void TriggerError(string message) - { + void TriggerError (string message) { errorMessage = string.Format("Error: '{0}' at line {1}", - message, lexer.lineNumber); + message, lexer.lineNumber); } - T EvalLexer(T value) - { + T EvalLexer (T value) { if (lexer.hasError) TriggerError("Lexical error ocurred"); diff --git a/spine-csharp/src/MathUtils.cs b/spine-csharp/src/MathUtils.cs index ad10ec217..23ca8ec2f 100644 --- a/spine-csharp/src/MathUtils.cs +++ b/spine-csharp/src/MathUtils.cs @@ -40,7 +40,7 @@ namespace Spine { static Random random = new Random(); - #if USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS +#if USE_FAST_SIN_COS_ATAN2_APPROXIMATIONS const int SIN_BITS = 14; // 16KB. Adjust for accuracy. const int SIN_MASK = ~(-1 << SIN_BITS); const int SIN_COUNT = SIN_MASK + 1; @@ -94,7 +94,7 @@ namespace Spine { atan = PI / 2 - z / (z * z + 0.28f); return y < 0f ? atan - PI : atan; } - #else +#else /// Returns the sine of a given angle in radians. static public float Sin (float radians) { return (float)Math.Sin(radians); @@ -119,18 +119,18 @@ namespace Spine { static public float Atan2 (float y, float x) { return (float)Math.Atan2(y, x); } - #endif +#endif static public float Clamp (float value, float min, float max) { if (value < min) return min; if (value > max) return max; return value; } - static public float RandomTriangle(float min, float max) { + static public float RandomTriangle (float min, float max) { return RandomTriangle(min, max, (min + max) * 0.5f); } - static public float RandomTriangle(float min, float max, float mode) { + static public float RandomTriangle (float min, float max, float mode) { float u = (float)random.NextDouble(); float d = max - min; if (u <= (mode - min) / d) return min + (float)Math.Sqrt(u * d * (mode - min)); @@ -142,31 +142,31 @@ namespace Spine { public static IInterpolation Pow2 = new Pow(2); public static IInterpolation Pow2Out = new PowOut(2); - protected abstract float Apply(float a); + protected abstract float Apply (float a); - public float Apply(float start, float end, float a) { + public float Apply (float start, float end, float a) { return start + (end - start) * Apply(a); } } - public class Pow: IInterpolation { + public class Pow : IInterpolation { public float Power { get; set; } - public Pow(float power) { + public Pow (float power) { Power = power; } - protected override float Apply(float a) { + protected override float Apply (float a) { if (a <= 0.5f) return (float)Math.Pow(a * 2, Power) / 2; return (float)Math.Pow((a - 1) * 2, Power) / (Power % 2 == 0 ? -2 : 2) + 1; } } public class PowOut : Pow { - public PowOut(float power) : base(power) { + public PowOut (float power) : base(power) { } - protected override float Apply(float a) { + protected override float Apply (float a) { return (float)Math.Pow(a - 1, Power) * (Power % 2 == 0 ? -1 : 1) + 1; } } diff --git a/spine-csharp/src/PathConstraint.cs b/spine-csharp/src/PathConstraint.cs index 31abec7a7..b73395bae 100644 --- a/spine-csharp/src/PathConstraint.cs +++ b/spine-csharp/src/PathConstraint.cs @@ -272,7 +272,7 @@ namespace Spine { } // Determine curve containing position. - for (;; curve++) { + for (; ; curve++) { float length = lengths[curve]; if (p > length) continue; if (curve == 0) @@ -383,7 +383,7 @@ namespace Spine { } // Determine curve containing position. - for (;; curve++) { + for (; ; curve++) { float length = curves[curve]; if (p > length) continue; if (curve == 0) @@ -438,7 +438,7 @@ namespace Spine { // Weight by segment length. p *= curveLength; - for (;; segment++) { + for (; ; segment++) { float length = segments[segment]; if (p > length) continue; if (segment == 0) diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index f7af22e88..07e12be33 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -117,7 +117,7 @@ namespace Spine { foreach (TransformConstraintData transformConstraintData in data.transformConstraints) transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); - pathConstraints = new ExposedList (data.pathConstraints.Count); + pathConstraints = new ExposedList(data.pathConstraints.Count); foreach (PathConstraintData pathConstraintData in data.pathConstraints) pathConstraints.Add(new PathConstraint(pathConstraintData, this)); @@ -177,7 +177,7 @@ namespace Spine { goto continue_outer; } } - continue_outer: {} + continue_outer: { } } for (int i = 0; i < boneCount; i++) @@ -332,7 +332,7 @@ namespace Spine { /// /// Temporarily sets the root bone as a child of the specified bone, then updates the world transform for each bone and applies /// all constraints. - /// + /// public void UpdateWorldTransform (Bone parent) { if (parent == null) throw new ArgumentNullException("parent", "parent cannot be null."); @@ -472,7 +472,7 @@ namespace Spine { /// Sets the skin used to look up attachments before looking in the . If the /// skin is changed, is called. /// - /// Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. + /// Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. /// If there was no old skin, each slot's setup mode attachment is attached from the new skin. /// /// After changing the skin, the visible attachments can be reset to those attached in the setup pose by calling diff --git a/spine-csharp/src/SkeletonBinary.cs b/spine-csharp/src/SkeletonBinary.cs index f2ce5bef7..b24068643 100644 --- a/spine-csharp/src/SkeletonBinary.cs +++ b/spine-csharp/src/SkeletonBinary.cs @@ -32,8 +32,8 @@ #endif using System; -using System.IO; using System.Collections.Generic; +using System.IO; using System.Runtime.Serialization; #if WINDOWS_STOREAPP @@ -70,7 +70,7 @@ namespace Spine { public const int CURVE_BEZIER = 2; public SkeletonBinary (AttachmentLoader attachmentLoader) - :base(attachmentLoader) { + : base(attachmentLoader) { } public SkeletonBinary (params Atlas[] atlasArray) @@ -92,17 +92,17 @@ namespace Spine { } #else public override SkeletonData ReadSkeletonData (string path) { - #if WINDOWS_PHONE +#if WINDOWS_PHONE using (var input = new BufferedStream(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) { - #else +#else using (var input = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { - #endif +#endif SkeletonData skeletonData = ReadSkeletonData(input); skeletonData.name = Path.GetFileNameWithoutExtension(path); return skeletonData; } } - #endif // WINDOWS_STOREAPP +#endif // WINDOWS_STOREAPP public static readonly TransformMode[] TransformModeValues = { TransformMode.Normal, @@ -539,7 +539,7 @@ namespace Spine { float scale = this.scale; int verticesLength = vertexCount << 1; Vertices vertices = new Vertices(); - if(!input.ReadBoolean()) { + if (!input.ReadBoolean()) { vertices.vertices = ReadFloatArray(input, verticesLength, scale); return vertices; } @@ -593,167 +593,167 @@ namespace Spine { for (int ii = 0, nn = input.ReadInt(true); ii < nn; ii++) { int timelineType = input.ReadByte(), frameCount = input.ReadInt(true), frameLast = frameCount - 1; switch (timelineType) { - case SLOT_ATTACHMENT: { - AttachmentTimeline timeline = new AttachmentTimeline(frameCount, slotIndex); - for (int frame = 0; frame < frameCount; frame++) - timeline.SetFrame(frame, input.ReadFloat(), input.ReadStringRef()); - timelines.Add(timeline); + case SLOT_ATTACHMENT: { + AttachmentTimeline timeline = new AttachmentTimeline(frameCount, slotIndex); + for (int frame = 0; frame < frameCount; frame++) + timeline.SetFrame(frame, input.ReadFloat(), input.ReadStringRef()); + timelines.Add(timeline); + break; + } + case SLOT_RGBA: { + RGBATimeline timeline = new RGBATimeline(frameCount, input.ReadInt(true), slotIndex); + float time = input.ReadFloat(); + float r = input.Read() / 255f, g = input.Read() / 255f; + float b = input.Read() / 255f, a = input.Read() / 255f; + for (int frame = 0, bezier = 0; ; frame++) { + timeline.SetFrame(frame, time, r, g, b, a); + if (frame == frameLast) break; + float time2 = input.ReadFloat(); + float r2 = input.Read() / 255f, g2 = input.Read() / 255f; + float b2 = input.Read() / 255f, a2 = input.Read() / 255f; + switch (input.ReadByte()) { + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1); + SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, a2, 1); break; } - case SLOT_RGBA: { - RGBATimeline timeline = new RGBATimeline(frameCount, input.ReadInt(true), slotIndex); - float time = input.ReadFloat(); - float r = input.Read() / 255f, g = input.Read() / 255f; - float b = input.Read() / 255f, a = input.Read() / 255f; - for (int frame = 0, bezier = 0; ; frame++) { - timeline.SetFrame(frame, time, r, g, b, a); - if (frame == frameLast) break; - float time2 = input.ReadFloat(); - float r2 = input.Read() / 255f, g2 = input.Read() / 255f; - float b2 = input.Read() / 255f, a2 = input.Read() / 255f; - switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1); - SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, a2, 1); - break; - } - time = time2; - r = r2; - g = g2; - b = b2; - a = a2; - } - timelines.Add(timeline); + time = time2; + r = r2; + g = g2; + b = b2; + a = a2; + } + timelines.Add(timeline); + break; + } + case SLOT_RGB: { + RGBTimeline timeline = new RGBTimeline(frameCount, input.ReadInt(true), slotIndex); + float time = input.ReadFloat(); + float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f; + for (int frame = 0, bezier = 0; ; frame++) { + timeline.SetFrame(frame, time, r, g, b); + if (frame == frameLast) break; + float time2 = input.ReadFloat(); + float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f; + switch (input.ReadByte()) { + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1); break; } - case SLOT_RGB: { - RGBTimeline timeline = new RGBTimeline(frameCount, input.ReadInt(true), slotIndex); - float time = input.ReadFloat(); - float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f; - for (int frame = 0, bezier = 0; ; frame++) { - timeline.SetFrame(frame, time, r, g, b); - if (frame == frameLast) break; - float time2 = input.ReadFloat(); - float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f; - switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1); - break; - } - time = time2; - r = r2; - g = g2; - b = b2; - } - timelines.Add(timeline); + time = time2; + r = r2; + g = g2; + b = b2; + } + timelines.Add(timeline); + break; + } + case SLOT_RGBA2: { + RGBA2Timeline timeline = new RGBA2Timeline(frameCount, input.ReadInt(true), slotIndex); + float time = input.ReadFloat(); + float r = input.Read() / 255f, g = input.Read() / 255f; + float b = input.Read() / 255f, a = input.Read() / 255f; + float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f; + for (int frame = 0, bezier = 0; ; frame++) { + timeline.SetFrame(frame, time, r, g, b, a, r2, g2, b2); + if (frame == frameLast) break; + float time2 = input.ReadFloat(); + float nr = input.Read() / 255f, ng = input.Read() / 255f; + float nb = input.Read() / 255f, na = input.Read() / 255f; + float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f; + switch (input.ReadByte()) { + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1); + SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, na, 1); + SetBezier(input, timeline, bezier++, frame, 4, time, time2, r2, nr2, 1); + SetBezier(input, timeline, bezier++, frame, 5, time, time2, g2, ng2, 1); + SetBezier(input, timeline, bezier++, frame, 6, time, time2, b2, nb2, 1); break; } - case SLOT_RGBA2: { - RGBA2Timeline timeline = new RGBA2Timeline(frameCount, input.ReadInt(true), slotIndex); - float time = input.ReadFloat(); - float r = input.Read() / 255f, g = input.Read() / 255f; - float b = input.Read() / 255f, a = input.Read() / 255f; - float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f; - for (int frame = 0, bezier = 0; ; frame++) { - timeline.SetFrame(frame, time, r, g, b, a, r2, g2, b2); - if (frame == frameLast) break; - float time2 = input.ReadFloat(); - float nr = input.Read() / 255f, ng = input.Read() / 255f; - float nb = input.Read() / 255f, na = input.Read() / 255f; - float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f; - switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1); - SetBezier(input, timeline, bezier++, frame, 3, time, time2, a, na, 1); - SetBezier(input, timeline, bezier++, frame, 4, time, time2, r2, nr2, 1); - SetBezier(input, timeline, bezier++, frame, 5, time, time2, g2, ng2, 1); - SetBezier(input, timeline, bezier++, frame, 6, time, time2, b2, nb2, 1); - break; - } - time = time2; - r = nr; - g = ng; - b = nb; - a = na; - r2 = nr2; - g2 = ng2; - b2 = nb2; - } - timelines.Add(timeline); + time = time2; + r = nr; + g = ng; + b = nb; + a = na; + r2 = nr2; + g2 = ng2; + b2 = nb2; + } + timelines.Add(timeline); + break; + } + case SLOT_RGB2: { + RGB2Timeline timeline = new RGB2Timeline(frameCount, input.ReadInt(true), slotIndex); + float time = input.ReadFloat(); + float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f; + float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f; + for (int frame = 0, bezier = 0; ; frame++) { + timeline.SetFrame(frame, time, r, g, b, r2, g2, b2); + if (frame == frameLast) break; + float time2 = input.ReadFloat(); + float nr = input.Read() / 255f, ng = input.Read() / 255f, nb = input.Read() / 255f; + float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f; + switch (input.ReadByte()) { + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1); + SetBezier(input, timeline, bezier++, frame, 3, time, time2, r2, nr2, 1); + SetBezier(input, timeline, bezier++, frame, 4, time, time2, g2, ng2, 1); + SetBezier(input, timeline, bezier++, frame, 5, time, time2, b2, nb2, 1); break; } - case SLOT_RGB2: { - RGB2Timeline timeline = new RGB2Timeline(frameCount, input.ReadInt(true), slotIndex); - float time = input.ReadFloat(); - float r = input.Read() / 255f, g = input.Read() / 255f, b = input.Read() / 255f; - float r2 = input.Read() / 255f, g2 = input.Read() / 255f, b2 = input.Read() / 255f; - for (int frame = 0, bezier = 0; ; frame++) { - timeline.SetFrame(frame, time, r, g, b, r2, g2, b2); - if (frame == frameLast) break; - float time2 = input.ReadFloat(); - float nr = input.Read() / 255f, ng = input.Read() / 255f, nb = input.Read() / 255f; - float nr2 = input.Read() / 255f, ng2 = input.Read() / 255f, nb2 = input.Read() / 255f; - switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1); - SetBezier(input, timeline, bezier++, frame, 3, time, time2, r2, nr2, 1); - SetBezier(input, timeline, bezier++, frame, 4, time, time2, g2, ng2, 1); - SetBezier(input, timeline, bezier++, frame, 5, time, time2, b2, nb2, 1); - break; - } - time = time2; - r = nr; - g = ng; - b = nb; - r2 = nr2; - g2 = ng2; - b2 = nb2; - } - timelines.Add(timeline); - break; - } - case SLOT_ALPHA: { - AlphaTimeline timeline = new AlphaTimeline(frameCount, input.ReadInt(true), slotIndex); - float time = input.ReadFloat(), a = input.Read() / 255f; - for (int frame = 0, bezier = 0; ; frame++) { - timeline.SetFrame(frame, time, a); - if (frame == frameLast) break; - float time2 = input.ReadFloat(); - float a2 = input.Read() / 255f; - switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, a, a2, 1); - break; - } - time = time2; - a = a2; - } - timelines.Add(timeline); + time = time2; + r = nr; + g = ng; + b = nb; + r2 = nr2; + g2 = ng2; + b2 = nb2; + } + timelines.Add(timeline); + break; + } + case SLOT_ALPHA: { + AlphaTimeline timeline = new AlphaTimeline(frameCount, input.ReadInt(true), slotIndex); + float time = input.ReadFloat(), a = input.Read() / 255f; + for (int frame = 0, bezier = 0; ; frame++) { + timeline.SetFrame(frame, time, a); + if (frame == frameLast) break; + float time2 = input.ReadFloat(); + float a2 = input.Read() / 255f; + switch (input.ReadByte()) { + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, a, a2, 1); break; } + time = time2; + a = a2; + } + timelines.Add(timeline); + break; + } } } } @@ -764,36 +764,36 @@ namespace Spine { for (int ii = 0, nn = input.ReadInt(true); ii < nn; ii++) { int type = input.ReadByte(), frameCount = input.ReadInt(true), bezierCount = input.ReadInt(true); switch (type) { - case BONE_ROTATE: - timelines.Add(ReadTimeline(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1)); - break; - case BONE_TRANSLATE: - timelines.Add(ReadTimeline(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale)); - break; - case BONE_TRANSLATEX: - timelines.Add(ReadTimeline(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale)); - break; - case BONE_TRANSLATEY: - timelines.Add(ReadTimeline(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale)); - break; - case BONE_SCALE: - timelines.Add(ReadTimeline(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1)); - break; - case BONE_SCALEX: - timelines.Add(ReadTimeline(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1)); - break; - case BONE_SCALEY: - timelines.Add(ReadTimeline(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1)); - break; - case BONE_SHEAR: - timelines.Add(ReadTimeline(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1)); - break; - case BONE_SHEARX: - timelines.Add(ReadTimeline(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1)); - break; - case BONE_SHEARY: - timelines.Add(ReadTimeline(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1)); - break; + case BONE_ROTATE: + timelines.Add(ReadTimeline(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1)); + break; + case BONE_TRANSLATE: + timelines.Add(ReadTimeline(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale)); + break; + case BONE_TRANSLATEX: + timelines.Add(ReadTimeline(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale)); + break; + case BONE_TRANSLATEY: + timelines.Add(ReadTimeline(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale)); + break; + case BONE_SCALE: + timelines.Add(ReadTimeline(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1)); + break; + case BONE_SCALEX: + timelines.Add(ReadTimeline(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1)); + break; + case BONE_SCALEY: + timelines.Add(ReadTimeline(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1)); + break; + case BONE_SHEAR: + timelines.Add(ReadTimeline(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1)); + break; + case BONE_SHEARX: + timelines.Add(ReadTimeline(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1)); + break; + case BONE_SHEARY: + timelines.Add(ReadTimeline(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1)); + break; } } } @@ -808,13 +808,13 @@ namespace Spine { if (frame == frameLast) break; float time2 = input.ReadFloat(), mix2 = input.ReadFloat(), softness2 = input.ReadFloat() * scale; switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale); - break; + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale); + break; } time = time2; mix = mix2; @@ -835,17 +835,17 @@ namespace Spine { float time2 = input.ReadFloat(), mixRotate2 = input.ReadFloat(), mixX2 = input.ReadFloat(), mixY2 = input.ReadFloat(), mixScaleX2 = input.ReadFloat(), mixScaleY2 = input.ReadFloat(), mixShearY2 = input.ReadFloat(); switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1); - SetBezier(input, timeline, bezier++, frame, 3, time, time2, mixScaleX, mixScaleX2, 1); - SetBezier(input, timeline, bezier++, frame, 4, time, time2, mixScaleY, mixScaleY2, 1); - SetBezier(input, timeline, bezier++, frame, 5, time, time2, mixShearY, mixShearY2, 1); - break; + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1); + SetBezier(input, timeline, bezier++, frame, 3, time, time2, mixScaleX, mixScaleX2, 1); + SetBezier(input, timeline, bezier++, frame, 4, time, time2, mixScaleY, mixScaleY2, 1); + SetBezier(input, timeline, bezier++, frame, 5, time, time2, mixShearY, mixShearY2, 1); + break; } time = time2; mixRotate = mixRotate2; @@ -884,14 +884,14 @@ namespace Spine { float time2 = input.ReadFloat(), mixRotate2 = input.ReadFloat(), mixX2 = input.ReadFloat(), mixY2 = input.ReadFloat(); switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1); - break; + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1); + break; } time = time2; mixRotate = mixRotate2; @@ -1022,7 +1022,7 @@ namespace Spine { /// Throws IOException when a read operation fails. private Timeline ReadTimeline (SkeletonInput input, CurveTimeline1 timeline, float scale) { float time = input.ReadFloat(), value = input.ReadFloat() * scale; - for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1;; frame++) { + for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1; ; frame++) { timeline.SetFrame(frame, time, value); if (frame == frameLast) break; float time2 = input.ReadFloat(), value2 = input.ReadFloat() * scale; @@ -1031,8 +1031,8 @@ namespace Spine { timeline.SetStepped(frame); break; case CURVE_BEZIER: - SetBezier (input, timeline, bezier++, frame, 0, time, time2, value, value2, scale); - break; + SetBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, scale); + break; } time = time2; value = value2; @@ -1043,18 +1043,18 @@ namespace Spine { /// Throws IOException when a read operation fails. private Timeline ReadTimeline (SkeletonInput input, CurveTimeline2 timeline, float scale) { float time = input.ReadFloat(), value1 = input.ReadFloat() * scale, value2 = input.ReadFloat() * scale; - for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1;; frame++) { + for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1; ; frame++) { timeline.SetFrame(frame, time, value1, value2); if (frame == frameLast) break; float time2 = input.ReadFloat(), nvalue1 = input.ReadFloat() * scale, nvalue2 = input.ReadFloat() * scale; switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale); - break; + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale); + break; } time = time2; value1 = nvalue1; @@ -1070,8 +1070,7 @@ namespace Spine { input.ReadFloat() * scale, time2, value2); } - internal class Vertices - { + internal class Vertices { public int[] bones; public float[] vertices; } diff --git a/spine-csharp/src/SkeletonData.cs b/spine-csharp/src/SkeletonData.cs index e6f70750b..d67f48ec9 100644 --- a/spine-csharp/src/SkeletonData.cs +++ b/spine-csharp/src/SkeletonData.cs @@ -43,7 +43,7 @@ namespace Spine { internal ExposedList ikConstraints = new ExposedList(); internal ExposedList transformConstraints = new ExposedList(); internal ExposedList pathConstraints = new ExposedList(); - internal float x , y, width, height; + internal float x, y, width, height; internal string version, hash; // Nonessential. diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs index e79913f91..465398210 100644 --- a/spine-csharp/src/SkeletonJson.cs +++ b/spine-csharp/src/SkeletonJson.cs @@ -32,8 +32,8 @@ #endif using System; -using System.IO; using System.Collections.Generic; +using System.IO; #if WINDOWS_STOREAPP using System.Threading.Tasks; @@ -77,17 +77,17 @@ namespace Spine { } #else public override SkeletonData ReadSkeletonData (string path) { - #if WINDOWS_PHONE +#if WINDOWS_PHONE using (var reader = new StreamReader(Microsoft.Xna.Framework.TitleContainer.OpenStream(path))) { - #else +#else using (var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))) { - #endif +#endif SkeletonData skeletonData = ReadSkeletonData(reader); skeletonData.name = Path.GetFileNameWithoutExtension(path); return skeletonData; } } - #endif +#endif public SkeletonData ReadSkeletonData (TextReader reader) { if (reader == null) throw new ArgumentNullException("reader", "reader cannot be null."); @@ -178,7 +178,7 @@ namespace Spine { foreach (Dictionary constraintMap in (List)root["ik"]) { IkConstraintData data = new IkConstraintData((string)constraintMap["name"]); data.order = GetInt(constraintMap, "order", 0); - data.skinRequired = GetBoolean(constraintMap,"skin", false); + data.skinRequired = GetBoolean(constraintMap, "skin", false); if (constraintMap.ContainsKey("bones")) { foreach (string boneName in (List)constraintMap["bones"]) { @@ -207,7 +207,7 @@ namespace Spine { foreach (Dictionary constraintMap in (List)root["transform"]) { TransformConstraintData data = new TransformConstraintData((string)constraintMap["name"]); data.order = GetInt(constraintMap, "order", 0); - data.skinRequired = GetBoolean(constraintMap,"skin", false); + data.skinRequired = GetBoolean(constraintMap, "skin", false); if (constraintMap.ContainsKey("bones")) { foreach (string boneName in (List)constraintMap["bones"]) { @@ -243,11 +243,11 @@ namespace Spine { } // Path constraints. - if(root.ContainsKey("path")) { + if (root.ContainsKey("path")) { foreach (Dictionary constraintMap in (List)root["path"]) { PathConstraintData data = new PathConstraintData((string)constraintMap["name"]); data.order = GetInt(constraintMap, "order", 0); - data.skinRequired = GetBoolean(constraintMap,"skin", false); + data.skinRequired = GetBoolean(constraintMap, "skin", false); if (constraintMap.ContainsKey("bones")) { foreach (string boneName in (List)constraintMap["bones"]) { @@ -418,78 +418,78 @@ namespace Spine { return box; case AttachmentType.Mesh: case AttachmentType.Linkedmesh: { - MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); - if (mesh == null) return null; - mesh.Path = path; + MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.Path = path; - if (map.ContainsKey("color")) { - var color = (string)map["color"]; - mesh.r = ToColor(color, 0); - mesh.g = ToColor(color, 1); - mesh.b = ToColor(color, 2); - mesh.a = ToColor(color, 3); - } + if (map.ContainsKey("color")) { + var color = (string)map["color"]; + mesh.r = ToColor(color, 0); + mesh.g = ToColor(color, 1); + mesh.b = ToColor(color, 2); + mesh.a = ToColor(color, 3); + } - mesh.Width = GetFloat(map, "width", 0) * scale; - mesh.Height = GetFloat(map, "height", 0) * scale; + mesh.Width = GetFloat(map, "width", 0) * scale; + mesh.Height = GetFloat(map, "height", 0) * scale; - string parent = GetString(map, "parent", null); - if (parent != null) { - linkedMeshes.Add(new LinkedMesh(mesh, GetString(map, "skin", null), slotIndex, parent, GetBoolean(map, "deform", true))); - return mesh; - } - - float[] uvs = GetFloatArray(map, "uvs", 1); - ReadVertices(map, mesh, uvs.Length); - mesh.triangles = GetIntArray(map, "triangles"); - mesh.regionUVs = uvs; - mesh.UpdateUVs(); - - if (map.ContainsKey("hull")) mesh.HullLength = GetInt(map, "hull", 0) << 1; - if (map.ContainsKey("edges")) mesh.Edges = GetIntArray(map, "edges"); + string parent = GetString(map, "parent", null); + if (parent != null) { + linkedMeshes.Add(new LinkedMesh(mesh, GetString(map, "skin", null), slotIndex, parent, GetBoolean(map, "deform", true))); return mesh; } + + float[] uvs = GetFloatArray(map, "uvs", 1); + ReadVertices(map, mesh, uvs.Length); + mesh.triangles = GetIntArray(map, "triangles"); + mesh.regionUVs = uvs; + mesh.UpdateUVs(); + + if (map.ContainsKey("hull")) mesh.HullLength = GetInt(map, "hull", 0) << 1; + if (map.ContainsKey("edges")) mesh.Edges = GetIntArray(map, "edges"); + return mesh; + } case AttachmentType.Path: { - PathAttachment pathAttachment = attachmentLoader.NewPathAttachment(skin, name); - if (pathAttachment == null) return null; - pathAttachment.closed = GetBoolean(map, "closed", false); - pathAttachment.constantSpeed = GetBoolean(map, "constantSpeed", true); + PathAttachment pathAttachment = attachmentLoader.NewPathAttachment(skin, name); + if (pathAttachment == null) return null; + pathAttachment.closed = GetBoolean(map, "closed", false); + pathAttachment.constantSpeed = GetBoolean(map, "constantSpeed", true); - int vertexCount = GetInt(map, "vertexCount", 0); - ReadVertices(map, pathAttachment, vertexCount << 1); + int vertexCount = GetInt(map, "vertexCount", 0); + ReadVertices(map, pathAttachment, vertexCount << 1); - // potential BOZO see Java impl - pathAttachment.lengths = GetFloatArray(map, "lengths", scale); - return pathAttachment; - } + // potential BOZO see Java impl + pathAttachment.lengths = GetFloatArray(map, "lengths", scale); + return pathAttachment; + } case AttachmentType.Point: { - PointAttachment point = attachmentLoader.NewPointAttachment(skin, name); - if (point == null) return null; - point.x = GetFloat(map, "x", 0) * scale; - point.y = GetFloat(map, "y", 0) * scale; - point.rotation = GetFloat(map, "rotation", 0); + PointAttachment point = attachmentLoader.NewPointAttachment(skin, name); + if (point == null) return null; + point.x = GetFloat(map, "x", 0) * scale; + point.y = GetFloat(map, "y", 0) * scale; + point.rotation = GetFloat(map, "rotation", 0); - //string color = GetString(map, "color", null); - //if (color != null) point.color = color; - return point; - } + //string color = GetString(map, "color", null); + //if (color != null) point.color = color; + return point; + } case AttachmentType.Clipping: { - ClippingAttachment clip = attachmentLoader.NewClippingAttachment(skin, name); - if (clip == null) return null; + ClippingAttachment clip = attachmentLoader.NewClippingAttachment(skin, name); + if (clip == null) return null; - string end = GetString(map, "end", null); - if (end != null) { - SlotData slot = skeletonData.FindSlot(end); - if (slot == null) throw new Exception("Clipping end slot not found: " + end); - clip.EndSlot = slot; - } - - ReadVertices(map, clip, GetInt(map, "vertexCount", 0) << 1); - - //string color = GetString(map, "color", null); - // if (color != null) clip.color = color; - return clip; + string end = GetString(map, "end", null); + if (end != null) { + SlotData slot = skeletonData.FindSlot(end); + if (slot == null) throw new Exception("Clipping end slot not found: " + end); + clip.EndSlot = slot; } + + ReadVertices(map, clip, GetInt(map, "vertexCount", 0) << 1); + + //string color = GetString(map, "color", null); + // if (color != null) clip.color = color; + return clip; + } } return null; } @@ -557,7 +557,7 @@ namespace Spine { float g = ToColor(color, 1); float b = ToColor(color, 2); float a = ToColor(color, 3); - for (int frame = 0, bezier = 0;; frame++) { + for (int frame = 0, bezier = 0; ; frame++) { timeline.SetFrame(frame, time, r, g, b, a); if (!keyMapEnumerator.MoveNext()) { timeline.Shrink(bezier); @@ -632,7 +632,7 @@ namespace Spine { keyMapEnumerator.MoveNext(); timelines.Add(ReadTimeline(ref keyMapEnumerator, new AlphaTimeline(values.Count, values.Count, slotIndex), 0, 1)); - } else if (timelineName == "rgba2") { + } else if (timelineName == "rgba2") { var timeline = new RGBA2Timeline(values.Count, values.Count * 7, slotIndex); var keyMapEnumerator = values.GetEnumerator(); @@ -1127,7 +1127,7 @@ namespace Spine { timeline.SetBezier(bezier, frame, value, time1, value1, cx1, cy1, cx2, cy2, time2, value2); } - static float[] GetFloatArray(Dictionary map, string name, float scale) { + static float[] GetFloatArray (Dictionary map, string name, float scale) { var list = (List)map[name]; var values = new float[list.Count]; if (scale == 1) { @@ -1140,7 +1140,7 @@ namespace Spine { return values; } - static int[] GetIntArray(Dictionary map, string name) { + static int[] GetIntArray (Dictionary map, string name) { var list = (List)map[name]; var values = new int[list.Count]; for (int i = 0, n = list.Count; i < n; i++) @@ -1148,27 +1148,27 @@ namespace Spine { return values; } - static float GetFloat(Dictionary map, string name, float defaultValue) { + static float GetFloat (Dictionary map, string name, float defaultValue) { if (!map.ContainsKey(name)) return defaultValue; return (float)map[name]; } - static int GetInt(Dictionary map, string name, int defaultValue) { + static int GetInt (Dictionary map, string name, int defaultValue) { if (!map.ContainsKey(name)) return defaultValue; return (int)(float)map[name]; } - static bool GetBoolean(Dictionary map, string name, bool defaultValue) { + static bool GetBoolean (Dictionary map, string name, bool defaultValue) { if (!map.ContainsKey(name)) return defaultValue; return (bool)map[name]; } - static string GetString(Dictionary map, string name, string defaultValue) { + static string GetString (Dictionary map, string name, string defaultValue) { if (!map.ContainsKey(name)) return defaultValue; return (string)map[name]; } - static float ToColor(string hexString, int colorIndex, int expectedLength = 8) { + static float ToColor (string hexString, int colorIndex, int expectedLength = 8) { if (hexString.Length != expectedLength) throw new ArgumentException("Color hexidecimal length must be " + expectedLength + ", recieved: " + hexString, "hexString"); return Convert.ToInt32(hexString.Substring(colorIndex * 2, 2), 16) / (float)255; diff --git a/spine-csharp/src/SkeletonLoader.cs b/spine-csharp/src/SkeletonLoader.cs index f6cbffdcd..69e66011c 100644 --- a/spine-csharp/src/SkeletonLoader.cs +++ b/spine-csharp/src/SkeletonLoader.cs @@ -28,8 +28,8 @@ *****************************************************************************/ using System; -using System.IO; using System.Collections.Generic; +using System.IO; namespace Spine { diff --git a/spine-csharp/src/Slot.cs b/spine-csharp/src/Slot.cs index b6b14f25c..92165c2cb 100644 --- a/spine-csharp/src/Slot.cs +++ b/spine-csharp/src/Slot.cs @@ -62,7 +62,7 @@ namespace Spine { } /// Copy constructor. - public Slot(Slot slot, Bone bone) { + public Slot (Slot slot, Bone bone) { if (slot == null) throw new ArgumentNullException("slot", "slot cannot be null."); if (bone == null) throw new ArgumentNullException("bone", "bone cannot be null."); data = slot.data; @@ -106,7 +106,7 @@ namespace Spine { /// color tinting. public float A { get { return a; } set { a = value; } } - public void ClampColor() { + public void ClampColor () { r = MathUtils.Clamp(r, 0, 1); g = MathUtils.Clamp(g, 0, 1); b = MathUtils.Clamp(b, 0, 1); diff --git a/spine-csharp/src/SlotData.cs b/spine-csharp/src/SlotData.cs index a51b2949e..7358c5772 100644 --- a/spine-csharp/src/SlotData.cs +++ b/spine-csharp/src/SlotData.cs @@ -62,7 +62,7 @@ namespace Spine { public BlendMode BlendMode { get { return blendMode; } set { blendMode = value; } } public SlotData (int index, String name, BoneData boneData) { - if (index < 0) throw new ArgumentException ("index must be >= 0.", "index"); + if (index < 0) throw new ArgumentException("index must be >= 0.", "index"); if (name == null) throw new ArgumentNullException("name", "name cannot be null."); if (boneData == null) throw new ArgumentNullException("boneData", "boneData cannot be null."); this.index = index; diff --git a/spine-csharp/src/TransformConstraint.cs b/spine-csharp/src/TransformConstraint.cs index 804c61f44..00fc7be9a 100644 --- a/spine-csharp/src/TransformConstraint.cs +++ b/spine-csharp/src/TransformConstraint.cs @@ -57,7 +57,7 @@ namespace Spine { mixShearY = data.mixShearY; bones = new ExposedList(); foreach (BoneData boneData in data.bones) - bones.Add (skeleton.FindBone(boneData.name)); + bones.Add(skeleton.FindBone(boneData.name)); target = skeleton.FindBone(data.target.name); } diff --git a/spine-monogame/example/ExampleGame.cs b/spine-monogame/example/ExampleGame.cs index 27e537a59..607fe06cf 100644 --- a/spine-monogame/example/ExampleGame.cs +++ b/spine-monogame/example/ExampleGame.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using System; namespace Spine { @@ -40,19 +40,19 @@ namespace Spine { private MouseState lastMouseState; protected Boolean mouseClicked = false; - public Screen(Example game) { + public Screen (Example game) { this.game = game; skeletonRenderer = new SkeletonRenderer(game.GraphicsDevice); skeletonRenderer.PremultipliedAlpha = false; } - public void UpdateInput() { + public void UpdateInput () { MouseState state = Mouse.GetState(); mouseClicked = lastMouseState.LeftButton == ButtonState.Pressed && state.LeftButton == ButtonState.Released; lastMouseState = state; } - public abstract void Render(float deltaTime); + public abstract void Render (float deltaTime); } /// @@ -63,7 +63,7 @@ namespace Spine { Skeleton skeleton; AnimationState state; - public RaptorScreen(Example game) : base (game) { + public RaptorScreen (Example game) : base(game) { // Load the texture atlas atlas = new Atlas("data/raptor.atlas", new XnaTextureLoader(game.GraphicsDevice)); @@ -85,7 +85,7 @@ namespace Spine { state.SetAnimation(0, "walk", true); } - public override void Render(float deltaTime) { + public override void Render (float deltaTime) { // Update the animation state and apply the animations // to the skeleton state.Update(deltaTime); @@ -116,7 +116,7 @@ namespace Spine { Skeleton skeleton; AnimationState state; - public TankScreen(Example game) : base(game) { + public TankScreen (Example game) : base(game) { // Instantiate and configure the two color tinting effect and // assign it to the skeleton renderer var twoColorTintEffect = game.Content.Load("Content\\SpineEffect"); @@ -140,7 +140,7 @@ namespace Spine { state.SetAnimation(0, "shoot", true); } - public override void Render(float deltaTime) { + public override void Render (float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); @@ -169,7 +169,7 @@ namespace Spine { Skeleton skeleton; AnimationState state; - public SpineboyScreen(Example game) : base(game) { + public SpineboyScreen (Example game) : base(game) { atlas = new Atlas("data/spineboy.atlas", new XnaTextureLoader(game.GraphicsDevice)); SkeletonBinary binary = new SkeletonBinary(atlas); @@ -197,7 +197,7 @@ namespace Spine { state.AddAnimation(0, "run", true, 0); } - public override void Render(float deltaTime) { + public override void Render (float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); skeleton.UpdateWorldTransform(); @@ -223,7 +223,7 @@ namespace Spine { Skeleton skeleton; AnimationState state; - public MixAndMatchScreen(Example game) : base(game) { + public MixAndMatchScreen (Example game) : base(game) { atlas = new Atlas("data/mix-and-match.atlas", new XnaTextureLoader(game.GraphicsDevice)); SkeletonJson json = new SkeletonJson(atlas); @@ -256,7 +256,7 @@ namespace Spine { skeleton.SetSkin(mixAndMatchSkin); } - public override void Render(float deltaTime) { + public override void Render (float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); skeleton.UpdateWorldTransform(); @@ -276,7 +276,7 @@ namespace Spine { GraphicsDeviceManager graphics; public Screen currentScreen; - public Example() { + public Example () { IsMouseVisible = true; graphics = new GraphicsDeviceManager(this); @@ -285,15 +285,15 @@ namespace Spine { graphics.PreferredBackBufferHeight = 600; } - protected override void LoadContent() { + protected override void LoadContent () { currentScreen = new MixAndMatchScreen(this); } - protected override void Update(GameTime gameTime) { + protected override void Update (GameTime gameTime) { currentScreen.UpdateInput(); } - protected override void Draw(GameTime gameTime) { + protected override void Draw (GameTime gameTime) { currentScreen.Render((float)(gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0)); } } diff --git a/spine-monogame/example/ExampleProgram.cs b/spine-monogame/example/ExampleProgram.cs index ccc243530..aae41d37c 100644 --- a/spine-monogame/example/ExampleProgram.cs +++ b/spine-monogame/example/ExampleProgram.cs @@ -30,11 +30,11 @@ using System; namespace Spine { - static class ExampleProgram { - static void Main (string[] args) { - using (Example game = new Example()) { - game.Run(); - } - } - } + static class ExampleProgram { + static void Main (string[] args) { + using (Example game = new Example()) { + game.Run(); + } + } + } } diff --git a/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs b/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs index 21aca3361..2c7da4934 100644 --- a/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs +++ b/spine-unity/Assets/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs @@ -27,14 +27,12 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - using Spine; using Spine.Unity; - +using System.Collections; +using System.Collections.Generic; using System.Text; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineAnimationTesterTool : MonoBehaviour, IHasSkeletonDataAsset, IHasSkeletonComponent { @@ -48,7 +46,7 @@ namespace Spine.Unity.Examples { public bool useOverrideAttachmentThreshold = true; - [Range(0f,1f)] + [Range(0f, 1f)] public float attachmentThreshold = 0.5f; public bool useOverrideDrawOrderThreshold; diff --git a/spine-unity/Assets/Spine Examples/Scripts/AttackSpineboy.cs b/spine-unity/Assets/Spine Examples/Scripts/AttackSpineboy.cs index da58a6962..aaa928f42 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/AttackSpineboy.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/AttackSpineboy.cs @@ -56,7 +56,7 @@ namespace Spine.Unity.Examples { if (currentHealth > 0) { spineboy.AnimationState.SetAnimation(0, hit, false); spineboy.AnimationState.AddAnimation(0, idle, true, 0); - gauge.fillPercent = (float)currentHealth/(float)maxHealth; + gauge.fillPercent = (float)currentHealth / (float)maxHealth; onAttack.Invoke(); } else { if (currentHealth >= 0) { diff --git a/spine-unity/Assets/Spine Examples/Scripts/FootSoldierExample.cs b/spine-unity/Assets/Spine Examples/Scripts/FootSoldierExample.cs index e723b5ab9..732f501b8 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/FootSoldierExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/FootSoldierExample.cs @@ -29,9 +29,9 @@ // Contributed by: Mitch Thompson -using UnityEngine; -using System.Collections; using Spine.Unity; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class FootSoldierExample : MonoBehaviour { @@ -81,7 +81,7 @@ namespace Spine.Unity.Examples { skeletonAnimation.AnimationName = moveAnimation; skeletonAnimation.Skeleton.ScaleX = 1; transform.Translate(moveSpeed * Time.deltaTime, 0, 0); - } else if(Input.GetKey(leftKey)) { + } else if (Input.GetKey(leftKey)) { skeletonAnimation.AnimationName = moveAnimation; skeletonAnimation.Skeleton.ScaleX = -1; transform.Translate(-moveSpeed * Time.deltaTime, 0, 0); @@ -91,7 +91,7 @@ namespace Spine.Unity.Examples { } } - IEnumerator Blink() { + IEnumerator Blink () { while (true) { yield return new WaitForSeconds(Random.Range(0.25f, 3f)); skeletonAnimation.Skeleton.SetAttachment(eyesSlot, blinkAttachment); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs index ea2e63adc..28223736b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity; using UnityEngine; using UnityEngine.Events; -using Spine.Unity; namespace Spine.Unity.Examples { @@ -188,29 +188,29 @@ namespace Spine.Unity.Examples { // When the state changes, notify the animation handle of the new state. string stateName = null; switch (currentState) { - case CharacterState.Idle: - stateName = "idle"; - break; - case CharacterState.Walk: - stateName = "walk"; - break; - case CharacterState.Run: - stateName = "run"; - break; - case CharacterState.Crouch: - stateName = "crouch"; - break; - case CharacterState.Rise: - stateName = "rise"; - break; - case CharacterState.Fall: - stateName = "fall"; - break; - case CharacterState.Attack: - stateName = "attack"; - break; - default: - break; + case CharacterState.Idle: + stateName = "idle"; + break; + case CharacterState.Walk: + stateName = "walk"; + break; + case CharacterState.Run: + stateName = "run"; + break; + case CharacterState.Crouch: + stateName = "crouch"; + break; + case CharacterState.Rise: + stateName = "rise"; + break; + case CharacterState.Fall: + stateName = "fall"; + break; + case CharacterState.Attack: + stateName = "attack"; + break; + default: + break; } animationHandle.PlayAnimationForState(stateName, 0); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs index 7daabb064..d45c65441 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class Raptor : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs index 3493c5c61..80a61e87f 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineBeginnerTwo : MonoBehaviour { @@ -92,7 +92,7 @@ namespace Spine.Unity.Examples { spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); yield return new WaitForSeconds(1f); - skeleton.ScaleX = -1; // skeleton allows you to flip the skeleton. + skeleton.ScaleX = -1; // skeleton allows you to flip the skeleton. spineAnimationState.SetAnimation(0, idleTurnAnimationName, false); spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); yield return new WaitForSeconds(0.5f); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs index 6f51d1a99..27536d88f 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineBlinkPlayer : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs index 24cb1788d..dfc83abec 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineboyBeginnerInput : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs index 3737f9a8a..7faeb6045 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { [SelectionBase] @@ -46,7 +46,7 @@ namespace Spine.Unity.Examples { #endregion float lastShootTime; - public event System.Action ShootEvent; // Lets other scripts know when Spineboy is shooting. Check C# Documentation to learn more about events and delegates. + public event System.Action ShootEvent; // Lets other scripts know when Spineboy is shooting. Check C# Documentation to learn more about events and delegates. public event System.Action StartAimEvent; // Lets other scripts know when Spineboy is aiming. public event System.Action StopAimEvent; // Lets other scripts know when Spineboy is no longer aiming. @@ -60,7 +60,7 @@ namespace Spine.Unity.Examples { if (currentTime - lastShootTime > shootInterval) { lastShootTime = currentTime; - if (ShootEvent != null) ShootEvent(); // Fire the "ShootEvent" event. + if (ShootEvent != null) ShootEvent(); // Fire the "ShootEvent" event. } } @@ -88,7 +88,7 @@ namespace Spine.Unity.Examples { #endregion IEnumerator JumpRoutine () { - if (state == SpineBeginnerBodyState.Jumping) yield break; // Don't jump when already jumping. + if (state == SpineBeginnerBodyState.Jumping) yield break; // Don't jump when already jumping. state = SpineBeginnerBodyState.Jumping; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs index dfb0ecebc..f69b86820 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineboyBeginnerView : MonoBehaviour { @@ -70,7 +70,7 @@ namespace Spine.Unity.Examples { if (skeletonAnimation == null) return; if (model == null) return; - if ((skeletonAnimation.skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft + if ((skeletonAnimation.skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft Turn(model.facingLeft); } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs index 7f033d3f7..78149b02c 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs @@ -34,7 +34,7 @@ namespace Spine.Unity.Examples { public SkeletonAnimation skeletonAnimation; - [SpineBone(dataField:"skeletonAnimation")] + [SpineBone(dataField: "skeletonAnimation")] public string boneName; public Camera cam; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Goblins.cs b/spine-unity/Assets/Spine Examples/Scripts/Goblins.cs index 70b0dc8c4..4af2f5c05 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Goblins.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Goblins.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine; using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { public class Goblins : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs b/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs index 901ca43b4..75d98fee8 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/HurtFlashEffect.cs @@ -37,8 +37,8 @@ public class HurtFlashEffect : MonoBehaviour { public int flashCount = DefaultFlashCount; public Color flashColor = Color.white; - [Range(1f/120f, 1f/15f)] - public float interval = 1f/60f; + [Range(1f / 120f, 1f / 15f)] + public float interval = 1f / 60f; public string fillPhaseProperty = "_FillPhase"; public string fillColorProperty = "_FillColor"; diff --git a/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs b/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs index ad0753ef4..c75e48c1d 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs @@ -27,13 +27,12 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; +using Spine.Unity; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine; -using Spine.Unity; - namespace Spine.Unity.Examples { //[CreateAssetMenu(menuName = "Spine/SkeletonData Modifiers/Animation Match", order = 200)] diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs index 381ed541b..3e9cebc10 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipSystemExample.cs @@ -27,12 +27,11 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity.AttachmentTools; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine.Unity.AttachmentTools; - namespace Spine.Unity.Examples { public class EquipSystemExample : MonoBehaviour, IHasSkeletonDataAsset { @@ -54,7 +53,7 @@ namespace Spine.Unity.Examples { public string slot; [SpineSkin] public string templateSkin; - [SpineAttachment(skinField:"templateSkin")] + [SpineAttachment(skinField: "templateSkin")] public string templateAttachment; } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs index 73460358e..6948a506e 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/EquipsVisualsComponentExample.cs @@ -27,12 +27,11 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity.AttachmentTools; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine.Unity.AttachmentTools; - namespace Spine.Unity.Examples { public class EquipsVisualsComponentExample : MonoBehaviour { @@ -79,7 +78,7 @@ namespace Spine.Unity.Examples { if (runtimeAtlas) Destroy(runtimeAtlas); var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, - out runtimeMaterial, out runtimeAtlas, maxAtlasSize : 1024, clearCache: false); + out runtimeMaterial, out runtimeAtlas, maxAtlasSize: 1024, clearCache: false); collectedSkin.Clear(); // You can optionally clear the textures cache after each ore multiple repack operations are done. diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsButtonExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsButtonExample.cs index 7d64e22d0..daddefa4b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsButtonExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsButtonExample.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity; +using UnityEngine; using UnityEngine.UI; namespace Spine.Unity.Examples { @@ -37,7 +37,7 @@ namespace Spine.Unity.Examples { public SkeletonDataAsset skeletonDataAsset; public MixAndMatchSkinsExample skinsSystem; - [SpineSkin(dataField:"skeletonDataAsset")] public string itemSkin; + [SpineSkin(dataField: "skeletonDataAsset")] public string itemSkin; public MixAndMatchSkinsExample.ItemType itemType; void Start () { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsExample.cs b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsExample.cs index a0c4a6c70..2081a7840 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Mix and Match Character Customize/MixAndMatchSkinsExample.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity.AttachmentTools; using System.Collections.Generic; using UnityEngine; -using Spine.Unity.AttachmentTools; namespace Spine.Unity.Examples { @@ -77,7 +77,7 @@ namespace Spine.Unity.Examples { UpdateCombinedSkin(); } - public void NextHairSkin() { + public void NextHairSkin () { activeHairIndex = (activeHairIndex + 1) % hairSkins.Length; UpdateCharacterSkin(); UpdateCombinedSkin(); @@ -113,22 +113,22 @@ namespace Spine.Unity.Examples { UpdateCombinedSkin(); } - public void Equip(string itemSkin, ItemType itemType) { + public void Equip (string itemSkin, ItemType itemType) { switch (itemType) { - case ItemType.Cloth: - clothesSkin = itemSkin; - break; - case ItemType.Pants: - pantsSkin = itemSkin; - break; - case ItemType.Bag: - bagSkin = itemSkin; - break; - case ItemType.Hat: - hatSkin = itemSkin; - break; - default: - break; + case ItemType.Cloth: + clothesSkin = itemSkin; + break; + case ItemType.Pants: + pantsSkin = itemSkin; + break; + case ItemType.Bag: + bagSkin = itemSkin; + break; + case ItemType.Hat: + hatSkin = itemSkin; + break; + default: + break; } UpdateCombinedSkin(); } diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs index cd50fe433..26a73b4fd 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatch.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity.AttachmentTools; using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { diff --git a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs index 4b6b708a8..f606d5e4f 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MixAndMatchGraphic.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity.AttachmentTools; using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { diff --git a/spine-unity/Assets/Spine Examples/Scripts/RaggedySpineboy.cs b/spine-unity/Assets/Spine Examples/Scripts/RaggedySpineboy.cs index e7ce38565..e01a48e95 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/RaggedySpineboy.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/RaggedySpineboy.cs @@ -27,16 +27,16 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class RaggedySpineboy : MonoBehaviour { public LayerMask groundMask; public float restoreDuration = 0.5f; - public Vector2 launchVelocity = new Vector2(50,100); + public Vector2 launchVelocity = new Vector2(50, 100); Spine.Unity.Examples.SkeletonRagdoll2D ragdoll; Collider2D naturalCollider; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/BoneLocalOverride.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/BoneLocalOverride.cs index 6686c8286..66ddd2af7 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/BoneLocalOverride.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/BoneLocalOverride.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine; using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { public class BoneLocalOverride : MonoBehaviour { @@ -50,7 +50,7 @@ namespace Spine.Unity.Examples { ISkeletonAnimation spineComponent; Bone bone; - #if UNITY_EDITOR +#if UNITY_EDITOR void OnValidate () { if (Application.isPlaying) return; spineComponent = spineComponent ?? GetComponent(); @@ -58,14 +58,14 @@ namespace Spine.Unity.Examples { if (bone != null) bone.SetToSetupPose(); OverrideLocal(spineComponent); } - #endif +#endif void Awake () { spineComponent = GetComponent(); if (spineComponent == null) { this.enabled = false; return; } spineComponent.UpdateLocal += OverrideLocal; - if (bone == null) { this.enabled = false; return; } + if (bone == null) { this.enabled = false; return; } } void OverrideLocal (ISkeletonAnimation animated) { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/CombinedSkin.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/CombinedSkin.cs index 7c002eadd..44089d250 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/CombinedSkin.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/CombinedSkin.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity.AttachmentTools; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine.Unity.AttachmentTools; namespace Spine.Unity.Examples { public class CombinedSkin : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhost.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhost.cs index 2c81dd39f..d8c3711b2 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhost.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhost.cs @@ -29,8 +29,8 @@ // Contributed by: Mitch Thompson -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { @@ -44,7 +44,7 @@ namespace Spine.Unity.Examples { public bool ghostingEnabled = true; [Tooltip("The time between invididual ghost pieces being spawned.")] [UnityEngine.Serialization.FormerlySerializedAs("spawnRate")] - public float spawnInterval = 1f/30f; + public float spawnInterval = 1f / 30f; [Tooltip("Maximum number of ghosts that can exist at a time. If the fade speed is not fast enough, the oldest ghost will immediately disappear to enforce the maximum number.")] public int maximumGhosts = 10; public float fadeSpeed = 10; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhostRenderer.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhostRenderer.cs index c62faa983..370923237 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhostRenderer.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Ghost/SkeletonGhostRenderer.cs @@ -29,8 +29,8 @@ // Contributed by: Mitch Thompson -using UnityEngine; using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SkeletonGhostRenderer : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/AtlasRegionAttacher.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/AtlasRegionAttacher.cs index dd7beb9c4..5c45584e9 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/AtlasRegionAttacher.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/AtlasRegionAttacher.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections.Generic; using Spine; using Spine.Unity.AttachmentTools; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { /// diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs index 40a9856ca..98e5a1751 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs @@ -29,9 +29,9 @@ // Original Contribution by: Mitch Thompson -using UnityEngine; -using System.Collections.Generic; using Spine.Unity.AttachmentTools; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { public class SpriteAttacher : MonoBehaviour { @@ -45,7 +45,7 @@ namespace Spine.Unity.Examples { [SpineSlot] public string slot; #endregion - #if UNITY_EDITOR +#if UNITY_EDITOR void OnValidate () { var skeletonComponent = GetComponent(); var skeletonRenderer = skeletonComponent as SkeletonRenderer; @@ -70,7 +70,7 @@ namespace Spine.Unity.Examples { } } } - #endif +#endif RegionAttachment attachment; Slot spineSlot; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/OutlineSkeletonGraphic.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/OutlineSkeletonGraphic.cs index ba16d1c50..4f7a009f7 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/OutlineSkeletonGraphic.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/OutlineSkeletonGraphic.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { @@ -38,7 +38,7 @@ namespace Spine.Unity.Examples { public Material materialWithoutOutline; public Material materialWithOutline; - #if UNITY_EDITOR +#if UNITY_EDITOR void Reset () { skeletonGraphic = GetComponent(); @@ -51,7 +51,7 @@ namespace Spine.Unity.Examples { } } } - #endif +#endif void OnEnable () { if (skeletonGraphic == null) @@ -62,7 +62,7 @@ namespace Spine.Unity.Examples { skeletonGraphic.material = materialWithOutline; } - public void DisableOutlineRendering () { + public void DisableOutlineRendering () { skeletonGraphic.material = materialWithoutOutline; } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderExistingMesh.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderExistingMesh.cs index c4df6b00c..a579ead91 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderExistingMesh.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderExistingMesh.cs @@ -31,8 +31,8 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { @@ -42,8 +42,7 @@ namespace Spine.Unity.Examples { [ExecuteInEditMode] #endif [RequireComponent(typeof(MeshRenderer)), RequireComponent(typeof(MeshFilter))] - public class RenderExistingMesh : MonoBehaviour - { + public class RenderExistingMesh : MonoBehaviour { public MeshRenderer referenceRenderer; bool updateViaSkeletonCallback = false; @@ -101,21 +100,21 @@ namespace Spine.Unity.Examples { InitializeDict(); } - #if UNITY_EDITOR +#if UNITY_EDITOR private void Update () { if (!Application.isPlaying) { InitializeDict(); } } - #endif +#endif void LateUpdate () { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) { UpdateMaterials(); return; } - #endif +#endif if (updateViaSkeletonCallback) return; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RootMotionDeltaCompensation.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RootMotionDeltaCompensation.cs index 52f5f306e..67bacbee6 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RootMotionDeltaCompensation.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RootMotionDeltaCompensation.cs @@ -1,5 +1,5 @@ -using UnityEngine; -using Spine.Unity; +using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { @@ -38,7 +38,7 @@ namespace Spine.Unity.Examples { rootMotion.rootMotionTranslateYPerX = 0; } - void AdjustDelta() { + void AdjustDelta () { Vector3 toTarget = targetPosition.position - this.transform.position; rootMotion.AdjustRootMotionToDistance(toTarget, trackIndex, adjustX, adjustY, minScaleX, maxScaleX, minScaleY, maxScaleY, diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SetRigidbodySolverIterations.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SetRigidbodySolverIterations.cs index cf2faed23..11b1764e4 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SetRigidbodySolverIterations.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SetRigidbodySolverIterations.cs @@ -40,8 +40,7 @@ namespace Spine.Unity.Examples { /// will be overwritten by the provided value. /// [DisallowMultipleComponent] - public class SetRigidbodySolverIterations : MonoBehaviour - { + public class SetRigidbodySolverIterations : MonoBehaviour { public int solverIterations = 30; void Awake () { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonAnimationMulti/SkeletonAnimationMulti.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonAnimationMulti/SkeletonAnimationMulti.cs index 8658a4ede..48c8603f2 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonAnimationMulti/SkeletonAnimationMulti.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonAnimationMulti/SkeletonAnimationMulti.cs @@ -27,13 +27,12 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; +using Spine.Unity; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine; -using Spine.Unity; - namespace Spine.Unity { using Animation = Spine.Animation; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonColorInitialize.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonColorInitialize.cs index 79270106b..f3fd715ae 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonColorInitialize.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonColorInitialize.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System.Collections.Generic; -using UnityEngine; using Spine; using Spine.Unity; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Prototyping { /// @@ -46,7 +46,7 @@ namespace Spine.Unity.Prototyping { public Color color = Color.white; } - #if UNITY_EDITOR +#if UNITY_EDITOR void OnValidate () { var skeletonComponent = GetComponent(); if (skeletonComponent != null) { @@ -58,7 +58,7 @@ namespace Spine.Unity.Prototyping { } ApplySettings(); } - #endif +#endif void Start () { ApplySettings(); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonGraphicPlayAnimationAtEvent.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonGraphicPlayAnimationAtEvent.cs index 486b5a3b1..d5c54221e 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonGraphicPlayAnimationAtEvent.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonGraphicPlayAnimationAtEvent.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity; +using UnityEngine; public class SkeletonGraphicPlayAnimationAtEvent : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdoll2DInspector.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdoll2DInspector.cs index ec288a209..df25ad048 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdoll2DInspector.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdoll2DInspector.cs @@ -29,9 +29,9 @@ // Contributed by: Mitch Thompson -using UnityEngine; using UnityEditor; +using UnityEngine; namespace Spine.Unity.Examples { - public class SkeletonRagdoll2DInspector {} + public class SkeletonRagdoll2DInspector { } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdollInspector.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdollInspector.cs index 8deef1990..2cf7fd29b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdollInspector.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/Editor/SkeletonRagdollInspector.cs @@ -29,8 +29,8 @@ // Contributed by: Mitch Thompson -using UnityEngine; using UnityEditor; +using UnityEngine; namespace Spine.Unity.Examples { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs index a88194cd2..f2c293f1e 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs @@ -29,9 +29,9 @@ // Contributed by: Mitch Thompson -using UnityEngine; using System.Collections; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { [RequireComponent(typeof(SkeletonRenderer))] @@ -437,7 +437,7 @@ namespace Spine.Unity.Examples { return colliders; } - public class LayerFieldAttribute : PropertyAttribute {} + public class LayerFieldAttribute : PropertyAttribute { } } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs index b11294ee3..548f3c6ee 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs @@ -33,9 +33,9 @@ #define HINGE_JOINT_NEW_BEHAVIOUR #endif -using UnityEngine; using System.Collections; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { [RequireComponent(typeof(SkeletonRenderer))] @@ -174,7 +174,7 @@ namespace Spine.Unity.Examples { joint.GetComponent().mass = joint.connectedBody.mass * massFalloffFactor; - #if HINGE_JOINT_NEW_BEHAVIOUR +#if HINGE_JOINT_NEW_BEHAVIOUR float referenceAngle = (rbParent.transform.eulerAngles.z - t.eulerAngles.z + 360f) % 360f; float minAngle = referenceAngle - rotationLimit; float maxAngle = referenceAngle + rotationLimit; @@ -182,10 +182,10 @@ namespace Spine.Unity.Examples { minAngle -= 360f; maxAngle -= 360f; } - #else - float minAngle = - rotationLimit; +#else + float minAngle = -rotationLimit; float maxAngle = rotationLimit; - #endif +#endif joint.limits = new JointAngleLimits2D { min = minAngle, max = maxAngle @@ -457,7 +457,7 @@ namespace Spine.Unity.Examples { return new Vector3(flipX ? -1f : 1f, flipY ? -1f : 1f, 1f); } - #if UNITY_EDITOR +#if UNITY_EDITOR void OnDrawGizmosSelected () { if (isActive) { Gizmos.DrawWireSphere(transform.position, thickness * 1.2f); @@ -466,7 +466,7 @@ namespace Spine.Unity.Examples { Gizmos.DrawWireSphere(newTransformPos, thickness * 1.2f); } } - #endif +#endif } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityEyeConstraint.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityEyeConstraint.cs index ab481fc26..31730c393 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityEyeConstraint.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityEyeConstraint.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs index 3a0193455..f094531da 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityGroundConstraint.cs @@ -35,11 +35,11 @@ using UnityEngine; namespace Spine.Unity.Examples { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [RequireComponent(typeof(SkeletonUtilityBone))] public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs index cf19a9098..47471a53d 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Examples { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SlotTintBlackFollower.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SlotTintBlackFollower.cs index 98feb0ff2..163e0a363 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SlotTintBlackFollower.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SlotTintBlackFollower.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SpineEventUnityHandler.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SpineEventUnityHandler.cs index 518673811..2457495c5 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SpineEventUnityHandler.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SpineEventUnityHandler.cs @@ -60,7 +60,7 @@ namespace Spine.Unity.Prototyping { var state = animationStateComponent.AnimationState; foreach (var ep in events) { var eventData = skeletonData.FindEvent(ep.spineEvent); - ep.eventDelegate = ep.eventDelegate ?? delegate(TrackEntry trackEntry, Event e) { if (e.Data == eventData) ep.unityHandler.Invoke(); }; + ep.eventDelegate = ep.eventDelegate ?? delegate (TrackEntry trackEntry, Event e) { if (e.Data == eventData) ep.unityHandler.Invoke(); }; state.Event += ep.eventDelegate; } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpawnFromSkeletonDataExample.cs b/spine-unity/Assets/Spine Examples/Scripts/SpawnFromSkeletonDataExample.cs index 0887bbc5f..8626f4c4b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpawnFromSkeletonDataExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpawnFromSkeletonDataExample.cs @@ -38,7 +38,7 @@ namespace Spine.Unity.Examples { [Range(0, 100)] public int count = 20; - [SpineAnimation(dataField:"skeletonDataAsset")] + [SpineAnimation(dataField: "skeletonDataAsset")] public string startingAnimation; IEnumerator Start () { @@ -51,7 +51,7 @@ namespace Spine.Unity.Examples { var sa = SkeletonAnimation.NewSkeletonAnimationGameObject(skeletonDataAsset); // Spawn a new SkeletonAnimation GameObject. DoExtraStuff(sa, spineAnimation); // optional stuff for fun. sa.gameObject.name = i.ToString(); - yield return new WaitForSeconds(1f/8f); + yield return new WaitForSeconds(1f / 8f); } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineGauge.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineGauge.cs index 41271866d..af68c292f 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineGauge.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineGauge.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { [ExecuteInEditMode] @@ -36,7 +36,7 @@ namespace Spine.Unity.Examples { public class SpineGauge : MonoBehaviour { #region Inspector - [Range(0,1)] + [Range(0, 1)] public float fillPercent = 0; public AnimationReferenceAsset fillAnimation; #endregion diff --git a/spine-unity/Assets/Spine Examples/Scripts/Spineboy.cs b/spine-unity/Assets/Spine Examples/Scripts/Spineboy.cs index e5b843db5..d725ecf89 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Spineboy.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Spineboy.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using Spine; using Spine.Unity; +using UnityEngine; namespace Spine.Unity.Examples { public class Spineboy : MonoBehaviour { @@ -39,10 +39,10 @@ namespace Spine.Unity.Examples { skeletonAnimation = GetComponent(); // Get the SkeletonAnimation component for the GameObject this script is attached to. var animationState = skeletonAnimation.AnimationState; - animationState.Event += HandleEvent;; // Call our method any time an animation fires an event. + animationState.Event += HandleEvent; ; // Call our method any time an animation fires an event. animationState.End += (entry) => Debug.Log("start: " + entry.TrackIndex); // A lambda can be used for the callback instead of a method. - animationState.AddAnimation(0, "jump", false, 2); // Queue jump to be played on track 0 two seconds after the starting animation. + animationState.AddAnimation(0, "jump", false, 2); // Queue jump to be played on track 0 two seconds after the starting animation. animationState.AddAnimation(0, "run", true, 0); // Queue walk to be looped on track 0 after the jump animation. } diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs index 031855403..f4942b9a6 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs @@ -39,7 +39,7 @@ namespace Spine.Unity.Examples { [SpineSlot] public string eyeSlotName, mouthSlotName; - [SpineAttachment(slotField:"eyeSlotName")] + [SpineAttachment(slotField: "eyeSlotName")] public string shockEyeName, normalEyeName; [SpineAttachment(slotField: "mouthSlotName")] diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFootplanter.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFootplanter.cs index 33570b67c..32fd5e44b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFootplanter.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFootplanter.cs @@ -27,18 +27,17 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; +using Spine.Unity; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine; -using Spine.Unity; - namespace Spine.Unity.Examples { public class SpineboyFootplanter : MonoBehaviour { public float timeScale = 0.5f; - [SpineBone] public string nearBoneName, farBoneName; + [SpineBone] public string nearBoneName, farBoneName; [Header("Settings")] public Vector2 footSize; @@ -147,7 +146,7 @@ namespace Spine.Unity.Examples { // Default starting positions. nearFoot.worldPos = tpos; - nearFoot.worldPos .x -= comfyDistance; + nearFoot.worldPos.x -= comfyDistance; nearFoot.worldPosPrev = nearFoot.worldPosNext = nearFoot.worldPos; farFoot.worldPos = tpos; diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyPole.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyPole.cs index f4bd8faf6..bbe17b357 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyPole.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyPole.cs @@ -27,11 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; - using Spine.Unity.Examples; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineboyPole : MonoBehaviour { diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyPoleGraphic.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyPoleGraphic.cs index 6d5b643a3..178d71c91 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyPoleGraphic.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyPoleGraphic.cs @@ -27,11 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine.Unity; - using Spine.Unity.Examples; +using System.Collections; +using UnityEngine; namespace Spine.Unity.Examples { public class SpineboyPoleGraphic : MonoBehaviour { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/AnimationReferenceAssetEditor.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/AnimationReferenceAssetEditor.cs index fdbdb582c..2dc434f14 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/AnimationReferenceAssetEditor.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/AnimationReferenceAssetEditor.cs @@ -27,13 +27,12 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using System; using System.Collections; using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - using System.Reflection; -using System; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using Editor = UnityEditor.Editor; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs index b89178dfb..77a416935 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs @@ -29,23 +29,22 @@ #define SPINE_SKELETON_MECANIM - #if (UNITY_2017_4 || UNITY_2018_1_OR_NEWER ) - #define SPINE_UNITY_2018_PREVIEW_API - #endif +#if (UNITY_2017_4 || UNITY_2018_1_OR_NEWER) +#define SPINE_UNITY_2018_PREVIEW_API +#endif using System; -using System.Reflection; using System.Collections.Generic; +using System.Reflection; using UnityEditor; using UnityEngine; - using CompatibilityProblemInfo = Spine.Unity.SkeletonDataCompatibility.CompatibilityProblemInfo; namespace Spine.Unity.Editor { + using Animation = Spine.Animation; using Event = UnityEngine.Event; using Icons = SpineEditorUtilities.Icons; - using Animation = Spine.Animation; [CustomEditor(typeof(SkeletonDataAsset)), CanEditMultipleObjects] public class SkeletonDataAssetInspector : UnityEditor.Editor { @@ -57,14 +56,14 @@ namespace Spine.Unity.Editor { SerializedProperty atlasAssets, skeletonJSON, scale, fromAnimation, toAnimation, duration, defaultMix; SerializedProperty skeletonDataModifiers; SerializedProperty blendModeMaterials; - #if SPINE_TK2D +#if SPINE_TK2D SerializedProperty spriteCollection; - #endif +#endif - #if SPINE_SKELETON_MECANIM +#if SPINE_SKELETON_MECANIM static bool isMecanimExpanded = false; SerializedProperty controller; - #endif +#endif SkeletonDataAsset targetSkeletonDataAsset; SkeletonData targetSkeletonData; @@ -117,17 +116,17 @@ namespace Spine.Unity.Editor { skeletonDataModifiers = serializedObject.FindProperty("skeletonDataModifiers"); blendModeMaterials = serializedObject.FindProperty("blendModeMaterials"); - #if SPINE_SKELETON_MECANIM +#if SPINE_SKELETON_MECANIM controller = serializedObject.FindProperty("controller"); - #endif +#endif - #if SPINE_TK2D +#if SPINE_TK2D if (newAtlasAssets) atlasAssets.isExpanded = false; spriteCollection = serializedObject.FindProperty("spriteCollection"); - #else +#else // Analysis disable once ConvertIfToOrExpression if (newAtlasAssets) atlasAssets.isExpanded = true; - #endif +#endif // This handles the case where the managed editor assembly is unloaded before recompilation when code changes. AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload; @@ -234,15 +233,15 @@ namespace Spine.Unity.Editor { DrawUnityTools(); } else { - #if !SPINE_TK2D +#if !SPINE_TK2D // Draw Reimport Button using (new EditorGUI.DisabledGroupScope(skeletonJSON.objectReferenceValue == null)) { if (GUILayout.Button(SpineInspectorUtility.TempContent("Attempt Reimport", Icons.warning))) DoReimport(); } - #else +#else EditorGUILayout.HelpBox("Couldn't load SkeletonData.", MessageType.Error); - #endif +#endif DrawWarningList(); } @@ -295,15 +294,15 @@ namespace Spine.Unity.Editor { // Texture source field. using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel); - #if !SPINE_TK2D +#if !SPINE_TK2D EditorGUILayout.PropertyField(atlasAssets, true); - #else +#else using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) { EditorGUILayout.PropertyField(atlasAssets, true); } EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel); EditorGUILayout.PropertyField(spriteCollection, true); - #endif +#endif } // Mix settings. @@ -362,15 +361,15 @@ namespace Spine.Unity.Editor { void DrawAtlasAssetsFields () { EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel); - #if !SPINE_TK2D +#if !SPINE_TK2D EditorGUILayout.PropertyField(atlasAssets, true); - #else +#else using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) { EditorGUILayout.PropertyField(atlasAssets, true); } EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel); EditorGUILayout.PropertyField(spriteCollection, true); - #endif +#endif if (atlasAssets.arraySize == 0) EditorGUILayout.HelpBox("AtlasAssets array is empty. Skeleton's attachments will load without being mapped to images.", MessageType.Info); @@ -387,8 +386,7 @@ namespace Spine.Unity.Editor { if (hasNulls) { if (targetSkeletonDataAsset.atlasAssets.Length == 1) { EditorGUILayout.HelpBox("Atlas array cannot have null entries!", MessageType.None); - } - else { + } else { EditorGUILayout.HelpBox("Atlas array should not have null entries!", MessageType.Error); if (SpineInspectorUtility.CenteredButton(SpineInspectorUtility.TempContent("Remove null entries"))) { var trimmedAtlasAssets = new List(); @@ -539,8 +537,7 @@ namespace Spine.Unity.Editor { if (skin != defaultSkin) { defaultSkin.GetAttachments(i, slotAttachments); defaultSkin.GetAttachments(i, defaultSkinAttachments); - } - else { + } else { defaultSkin.GetAttachments(i, defaultSkinAttachments); } } @@ -580,7 +577,7 @@ namespace Spine.Unity.Editor { } void DrawUnityTools () { - #if SPINE_SKELETON_MECANIM +#if SPINE_SKELETON_MECANIM using (new SpineInspectorUtility.BoxScope()) { isMecanimExpanded = EditorGUILayout.Foldout(isMecanimExpanded, SpineInspectorUtility.TempContent("SkeletonMecanim", SpineInspectorUtility.UnityIcon())); if (isMecanimExpanded) { @@ -609,7 +606,7 @@ namespace Spine.Unity.Editor { } } } - #endif +#endif } void DrawWarningList () { @@ -632,14 +629,14 @@ namespace Spine.Unity.Editor { else warnings.Add("Skeleton data file is not a valid Spine JSON or binary file."); } else { - #if SPINE_TK2D +#if SPINE_TK2D bool searchForSpineAtlasAssets = (compatibilityProblemInfo == null); bool isSpriteCollectionNull = spriteCollection.objectReferenceValue == null; if (!isSpriteCollectionNull) searchForSpineAtlasAssets = false; - #else +#else // Analysis disable once ConvertToConstant.Local bool searchForSpineAtlasAssets = (compatibilityProblemInfo == null); - #endif +#endif if (searchForSpineAtlasAssets) { bool detectedNullAtlasEntry = false; @@ -673,10 +670,10 @@ namespace Spine.Unity.Editor { } } - #if SPINE_TK2D +#if SPINE_TK2D if (missingPaths.Count > 0) warnings.Add("Missing regions. SkeletonDataAsset requires tk2DSpriteCollectionData or Spine AtlasAssets."); - #endif +#endif } if (missingPaths != null) { @@ -692,7 +689,7 @@ namespace Spine.Unity.Editor { } void DoReimport () { - AssetUtility.ImportSpineContent(new [] { AssetDatabase.GetAssetPath(skeletonJSON.objectReferenceValue) }, null, true); + AssetUtility.ImportSpineContent(new[] { AssetDatabase.GetAssetPath(skeletonJSON.objectReferenceValue) }, null, true); preview.Clear(); InitializeEditor(); EditorUtility.SetDirty(targetSkeletonDataAsset); @@ -702,7 +699,7 @@ namespace Spine.Unity.Editor { EditorPrefs.SetString(LastSkinKey, skinName); } - bool NoProblems() { + bool NoProblems () { return warnings.Count == 0 && compatibilityProblemInfo == null; } @@ -760,11 +757,11 @@ namespace Spine.Unity.Editor { Camera PreviewUtilityCamera { get { if (previewRenderUtility == null) return null; - #if UNITY_2017_1_OR_NEWER +#if UNITY_2017_1_OR_NEWER return previewRenderUtility.camera; - #else +#else return previewRenderUtility.m_Camera; - #endif +#endif } } @@ -787,7 +784,8 @@ namespace Spine.Unity.Editor { set { if (IsValid) skeletonAnimation.timeScale = value; } } - public bool IsPlayingAnimation { get { + public bool IsPlayingAnimation { + get { if (!IsValid) return false; var currentTrack = skeletonAnimation.AnimationState.GetCurrent(0); return currentTrack != null && currentTrack.TimeScale > 0; @@ -862,7 +860,7 @@ namespace Spine.Unity.Editor { if (previewGameObject == null) { try { - previewGameObject = EditorInstantiation.InstantiateSkeletonAnimation(skeletonDataAsset, skinName, useObjectFactory:false).gameObject; + previewGameObject = EditorInstantiation.InstantiateSkeletonAnimation(skeletonDataAsset, skinName, useObjectFactory: false).gameObject; if (previewGameObject != null) { previewGameObject.hideFlags = HideFlags.HideAndDontSave; @@ -872,9 +870,9 @@ namespace Spine.Unity.Editor { skeletonAnimation.LateUpdate(); previewGameObject.GetComponent().enabled = false; - #if SPINE_UNITY_2018_PREVIEW_API +#if SPINE_UNITY_2018_PREVIEW_API previewRenderUtility.AddSingleGO(previewGameObject); - #endif +#endif } if (this.ActiveTrack != null) cameraAdjustEndFrame = EditorApplication.timeSinceStartup + skeletonAnimation.AnimationState.GetCurrent(0).Alpha; @@ -1002,14 +1000,14 @@ namespace Spine.Unity.Editor { Event current = Event.current; int controlID = GUIUtility.GetControlID(SliderHash, FocusType.Passive); switch (current.GetTypeForControl(controlID)) { - case EventType.ScrollWheel: - if (position.Contains(current.mousePosition)) { - cameraOrthoGoal += current.delta.y * 0.06f; - cameraOrthoGoal = Mathf.Max(0.01f, cameraOrthoGoal); - GUIUtility.hotControl = controlID; - current.Use(); - } - break; + case EventType.ScrollWheel: + if (position.Contains(current.mousePosition)) { + cameraOrthoGoal += current.delta.y * 0.06f; + cameraOrthoGoal = Mathf.Max(0.01f, cameraOrthoGoal); + GUIUtility.hotControl = controlID; + current.Use(); + } + break; } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineAtlasAssetInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineAtlasAssetInspector.cs index 8e9e3ee8f..1017ec1b5 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineAtlasAssetInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineAtlasAssetInspector.cs @@ -30,12 +30,12 @@ //#define BAKE_ALL_BUTTON //#define REGION_BAKING_MESH +using Spine; using System; using System.Collections.Generic; using System.Reflection; using UnityEditor; using UnityEngine; -using Spine; namespace Spine.Unity.Editor { using Event = UnityEngine.Event; @@ -72,12 +72,12 @@ namespace Spine.Unity.Editor { materials = serializedObject.FindProperty("materials"); materials.isExpanded = true; atlasAsset = (SpineAtlasAsset)target; - #if REGION_BAKING_MESH +#if REGION_BAKING_MESH UpdateBakedList(); - #endif +#endif } - #if REGION_BAKING_MESH +#if REGION_BAKING_MESH private List baked; private List bakedObjects; @@ -99,7 +99,7 @@ namespace Spine.Unity.Editor { } } } - #endif +#endif override public void OnInspectorGUI () { if (serializedObject.isEditingMultipleObjects) { @@ -155,7 +155,7 @@ namespace Spine.Unity.Editor { EditorGUILayout.Space(); - #if REGION_BAKING_MESH +#if REGION_BAKING_MESH if (atlasFile.objectReferenceValue != null) { Atlas atlas = asset.GetAtlas(); FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic); @@ -219,7 +219,7 @@ namespace Spine.Unity.Editor { } EditorGUI.indentLevel--; - #if BAKE_ALL_BUTTON +#if BAKE_ALL_BUTTON // Check state bool allBaked = true; bool allUnbaked = true; @@ -258,10 +258,10 @@ namespace Spine.Unity.Editor { } } - #endif +#endif } - #else +#else if (atlasFile.objectReferenceValue != null) { @@ -306,7 +306,7 @@ namespace Spine.Unity.Editor { } EditorGUI.indentLevel = baseIndent; } - #endif +#endif if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current)) atlasAsset.Clear(); @@ -320,7 +320,7 @@ namespace Spine.Unity.Editor { var sprites = new List(spriteSheet); var regions = SpineAtlasAssetInspector.GetRegions(atlas); - char[] FilenameDelimiter = {'.'}; + char[] FilenameDelimiter = { '.' }; int updatedCount = 0; int addedCount = 0; @@ -329,13 +329,13 @@ namespace Spine.Unity.Editor { string textureName = texture.name; bool pageMatch = string.Equals(pageName, textureName, StringComparison.Ordinal); -// if (pageMatch) { -// int pw = r.page.width; -// int ph = r.page.height; -// bool mismatchSize = pw != texture.width || pw > t.maxTextureSize || ph != texture.height || ph > t.maxTextureSize; -// if (mismatchSize) -// Debug.LogWarningFormat("Size mismatch found.\nExpected atlas size is {0}x{1}. Texture Import Max Size of texture '{2}'({4}x{5}) is currently set to {3}.", pw, ph, texture.name, t.maxTextureSize, texture.width, texture.height); -// } + // if (pageMatch) { + // int pw = r.page.width; + // int ph = r.page.height; + // bool mismatchSize = pw != texture.width || pw > t.maxTextureSize || ph != texture.height || ph > t.maxTextureSize; + // if (mismatchSize) + // Debug.LogWarningFormat("Size mismatch found.\nExpected atlas size is {0}x{1}. Texture Import Max Size of texture '{2}'({4}x{5}) is currently set to {3}.", pw, ph, texture.name, t.maxTextureSize, texture.width, texture.height); + // } int spriteIndex = pageMatch ? sprites.FindIndex( (s) => string.Equals(s.name, r.name, StringComparison.Ordinal) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineSpriteAtlasAssetInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineSpriteAtlasAssetInspector.cs index 6820b56e9..874f73316 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineSpriteAtlasAssetInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SpineSpriteAtlasAssetInspector.cs @@ -27,12 +27,12 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; using System; using System.Collections.Generic; using System.Reflection; using UnityEditor; using UnityEngine; -using Spine; namespace Spine.Unity.Editor { using Event = UnityEngine.Event; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs index 1603385f6..21677dcef 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using UnityEditor; using Spine.Unity; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { @@ -45,7 +45,7 @@ namespace Spine.Unity.Editor { bool needsReset; #region Context Menu Item - [MenuItem ("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject")] + [MenuItem("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject")] static void AddBoneFollowerGameObject (MenuCommand cmd) { var skeletonGraphic = cmd.context as SkeletonGraphic; var go = EditorInstantiation.NewGameObject("BoneFollower", true, typeof(RectTransform)); @@ -63,7 +63,7 @@ namespace Spine.Unity.Editor { } // Validate - [MenuItem ("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject", true)] + [MenuItem("CONTEXT/SkeletonGraphic/Add BoneFollower GameObject", true)] static bool ValidateAddBoneFollowerGameObject (MenuCommand cmd) { var skeletonGraphic = cmd.context as SkeletonGraphic; return skeletonGraphic.IsValid; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerInspector.cs index 17cc73978..a94488425 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerInspector.cs @@ -43,7 +43,7 @@ namespace Spine.Unity.Editor { bool needsReset; #region Context Menu Item - [MenuItem ("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject")] + [MenuItem("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject")] static void AddBoneFollowerGameObject (MenuCommand cmd) { var skeletonRenderer = cmd.context as SkeletonRenderer; var go = EditorInstantiation.NewGameObject("New BoneFollower", true); @@ -60,7 +60,7 @@ namespace Spine.Unity.Editor { } // Validate - [MenuItem ("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject", true)] + [MenuItem("CONTEXT/SkeletonRenderer/Add BoneFollower GameObject", true)] static bool ValidateAddBoneFollowerGameObject (MenuCommand cmd) { var skeletonRenderer = cmd.context as SkeletonRenderer; return skeletonRenderer.valid; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerGraphicInspector.cs index b1420afd1..d59f01f71 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerGraphicInspector.cs @@ -31,9 +31,9 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using Event = UnityEngine.Event; @@ -66,11 +66,11 @@ namespace Spine.Unity.Editor { public override void OnInspectorGUI () { - #if !NEW_PREFAB_SYSTEM +#if !NEW_PREFAB_SYSTEM bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab); - #else +#else bool isInspectingPrefab = false; - #endif +#endif // Note: when calling InitializeEditor() in OnEnable, it throws exception // "SerializedObjectNotCreatableException: Object at index 0 is null". @@ -109,10 +109,10 @@ namespace Spine.Unity.Editor { if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); InitializeEditor(); - #if !NEW_PREFAB_SYSTEM +#if !NEW_PREFAB_SYSTEM if (!isInspectingPrefab) rebuildRequired = true; - #endif +#endif } using (new SpineInspectorUtility.LabelWidthScope(150f)) { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerInspector.cs index 6e6909db6..8dad8994e 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoundingBoxFollowerInspector.cs @@ -31,9 +31,9 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using Event = UnityEngine.Event; @@ -66,11 +66,11 @@ namespace Spine.Unity.Editor { public override void OnInspectorGUI () { - #if !NEW_PREFAB_SYSTEM +#if !NEW_PREFAB_SYSTEM bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab); - #else +#else bool isInspectingPrefab = false; - #endif +#endif // Note: when calling InitializeEditor() in OnEnable, it throws exception // "SerializedObjectNotCreatableException: Object at index 0 is null". @@ -109,10 +109,10 @@ namespace Spine.Unity.Editor { if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); InitializeEditor(); - #if !NEW_PREFAB_SYSTEM +#if !NEW_PREFAB_SYSTEM if (!isInspectingPrefab) rebuildRequired = true; - #endif +#endif } using (new SpineInspectorUtility.LabelWidthScope(150f)) { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonAnimationInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonAnimationInspector.cs index c33232442..56ae78260 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonAnimationInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonAnimationInspector.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; using UnityEditor; using UnityEngine; -using Spine; namespace Spine.Unity.Editor { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicCustomMaterialsInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicCustomMaterialsInspector.cs index f9a1c2d78..2ad2fca8e 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicCustomMaterialsInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicCustomMaterialsInspector.cs @@ -27,13 +27,13 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity.Examples; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEditor; using UnityEngine; -using Spine.Unity.Examples; namespace Spine.Unity.Editor { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs index 40142f622..d8e2e1891 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs @@ -31,8 +31,8 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using Icons = SpineEditorUtilities.Icons; @@ -71,8 +71,7 @@ namespace Spine.Unity.Editor { return false; } return true; - } - else { + } else { var component = (SkeletonGraphic)target; return component.IsValid; } @@ -136,8 +135,7 @@ namespace Spine.Unity.Editor { foreach (var c in targets) { SpineEditorUtilities.ReloadSkeletonDataAssetAndComponent(c as SkeletonGraphic); } - } - else { + } else { foreach (var c in targets) { var component = c as SkeletonGraphic; if (!component.IsValid) { @@ -243,8 +241,7 @@ namespace Spine.Unity.Editor { meshGeneratorSettings.isExpanded = true; EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("'Multiple Canvas Renderers' must be enabled\nwhen 'Enable Separation' is enabled.", Icons.warning), GUILayout.Height(42), GUILayout.Width(340)); } - } - else if (meshRendersIncorrectlyWithSingleRenderer) { + } else if (meshRendersIncorrectlyWithSingleRenderer) { using (new SpineInspectorUtility.BoxScope()) { meshGeneratorSettings.isExpanded = true; EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("This mesh uses multiple atlas pages. You\n" + @@ -298,12 +295,12 @@ namespace Spine.Unity.Editor { if (TargetIsValid && !isInspectingPrefab) { EditorGUILayout.Space(); if (SpineInspectorUtility.CenteredButton(new GUIContent("Add Skeleton Utility", Icons.skeletonUtility), 21, true, 200f)) - foreach (var t in targets) { - var component = t as Component; - if (component.GetComponent() == null) { - component.gameObject.AddComponent(); + foreach (var t in targets) { + var component = t as Component; + if (component.GetComponent() == null) { + component.gameObject.AddComponent(); + } } - } } wasChanged |= EditorGUI.EndChangeCheck(); @@ -384,12 +381,11 @@ namespace Spine.Unity.Editor { separatorSlotNames.arraySize++; } GUILayout.EndHorizontal(); - } - else + } else EditorGUILayout.PropertyField(separatorSlotNames, new GUIContent(separatorSlotNames.displayName + string.Format("{0} [{1}]", terminalSlotWarning, separatorSlotNames.arraySize), SeparatorsDescription), true); EditorGUILayout.PropertyField(enableSeparatorSlots, SpineInspectorUtility.TempContent("Enable Separation", tooltip: "Whether to enable separation at the above separator slots.")); - EditorGUILayout.PropertyField(updateSeparatorPartLocation, SpineInspectorUtility.TempContent("Update Part Location", tooltip:"Update separator part GameObject location to match the position of the SkeletonGraphic. This can be helpful when re-parenting parts to a different GameObject.")); + EditorGUILayout.PropertyField(updateSeparatorPartLocation, SpineInspectorUtility.TempContent("Update Part Location", tooltip: "Update separator part GameObject location to match the position of the SkeletonGraphic. This can be helpful when re-parenting parts to a different GameObject.")); } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererCustomMaterialsInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererCustomMaterialsInspector.cs index 44c9f4a49..191edbf7c 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererCustomMaterialsInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererCustomMaterialsInspector.cs @@ -31,13 +31,13 @@ // Contributed by: Lost Polygon +using Spine.Unity.Examples; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEditor; using UnityEngine; -using Spine.Unity.Examples; namespace Spine.Unity.Editor { @@ -137,9 +137,9 @@ namespace Spine.Unity.Editor { if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Clear and Reapply Changes", tooltip: "Removes all non-serialized overrides in the SkeletonRenderer and reapplies the overrides on this component."))) { if (skeletonRenderer != null) { - #if SPINE_OPTIONAL_MATERIALOVERRIDE +#if SPINE_OPTIONAL_MATERIALOVERRIDE skeletonRenderer.CustomMaterialOverride.Clear(); - #endif +#endif skeletonRenderer.CustomSlotMaterials.Clear(); RemoveCustomMaterials(); SetCustomMaterials(); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs index f3904dae3..a21c01d7b 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs @@ -45,10 +45,10 @@ #define HAS_ON_POSTPROCESS_PREFAB #endif -using UnityEditor; using System.Collections.Generic; -using UnityEngine; using System.Reflection; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using Event = UnityEngine.Event; @@ -216,7 +216,7 @@ namespace Spine.Unity.Editor { } } - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT if (setMaskNoneMaterialsQueued) { setMaskNoneMaterialsQueued = false; foreach (var c in targets) @@ -243,7 +243,7 @@ namespace Spine.Unity.Editor { foreach (var c in targets) EditorDeleteMaskMaterials(c as SkeletonRenderer, SpriteMaskInteraction.VisibleOutsideMask); } - #endif +#endif #if NO_PREFAB_MESH if (isInspectingPrefab) { @@ -342,17 +342,17 @@ namespace Spine.Unity.Editor { if (updateWhenInvisible != null) EditorGUILayout.PropertyField(updateWhenInvisible, UpdateWhenInvisibleLabel); if (singleSubmesh != null) EditorGUILayout.PropertyField(singleSubmesh, SingleSubmeshLabel); - #if PER_MATERIAL_PROPERTY_BLOCKS +#if PER_MATERIAL_PROPERTY_BLOCKS if (fixDrawOrder != null) EditorGUILayout.PropertyField(fixDrawOrder, FixDrawOrderLabel); - #endif +#endif if (immutableTriangles != null) EditorGUILayout.PropertyField(immutableTriangles, ImmubleTrianglesLabel); EditorGUILayout.PropertyField(clearStateOnDisable, ClearStateOnDisableLabel); EditorGUILayout.Space(); - #if HAS_ON_POSTPROCESS_PREFAB +#if HAS_ON_POSTPROCESS_PREFAB if (fixPrefabOverrideViaMeshFilter != null) EditorGUILayout.PropertyField(fixPrefabOverrideViaMeshFilter, FixPrefabOverrideViaMeshFilterLabel); EditorGUILayout.Space(); - #endif +#endif } SeparatorsField(separatorSlotNames); @@ -374,7 +374,7 @@ namespace Spine.Unity.Editor { if (tangents != null) EditorGUILayout.PropertyField(tangents, TangentsLabel); } - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT EditorGUILayout.Space(); if (maskMaterialsNone.arraySize > 0 || maskMaterialsInside.arraySize > 0 || maskMaterialsOutside.arraySize > 0) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Mask Interaction Materials", SpineInspectorUtility.UnityIcon()), EditorStyles.boldLabel); @@ -389,7 +389,7 @@ namespace Spine.Unity.Editor { MaskMaterialsEditingField(ref setOutsideMaskMaterialsQueued, ref deleteOutsideMaskMaterialsQueued, maskMaterialsOutside, MaskMaterialsOutsideLabel, differentMaskModesSelected, allowDelete : true, isActiveMaterial: activeMaskInteractionValue == (int)SpriteMaskInteraction.VisibleOutsideMask); } - #endif +#endif EditorGUILayout.Space(); @@ -421,11 +421,11 @@ namespace Spine.Unity.Editor { } } - protected void SkeletonRootMotionParameter() { + protected void SkeletonRootMotionParameter () { SkeletonRootMotionParameter(targets); } - public static void SkeletonRootMotionParameter(Object[] targets) { + public static void SkeletonRootMotionParameter (Object[] targets) { int rootMotionComponentCount = 0; foreach (var t in targets) { var component = t as Component; @@ -454,7 +454,7 @@ namespace Spine.Unity.Editor { foreach (var t in targets) { var component = t as Component; var rootMotionComponent = component.GetComponent(); - if (rootMotionComponent != null) { + if (rootMotionComponent != null) { DestroyImmediate(rootMotionComponent); } } @@ -510,7 +510,7 @@ namespace Spine.Unity.Editor { } } - public void MaskMaterialsEditingField(ref bool wasSetRequested, ref bool wasDeleteRequested, + public void MaskMaterialsEditingField (ref bool wasSetRequested, ref bool wasDeleteRequested, SerializedProperty maskMaterials, GUIContent label, bool differentMaskModesSelected, bool allowDelete, bool isActiveMaterial) { using (new EditorGUILayout.HorizontalScope()) { @@ -531,8 +531,7 @@ namespace Spine.Unity.Editor { { if (GUILayout.Button(ClearMaterialButtonLabel, allowDelete ? EditorStyles.miniButtonMid : EditorStyles.miniButtonRight, GUILayout.Width(46f))) { maskMaterials.ClearArray(); - } - else if (allowDelete && GUILayout.Button(DeleteMaterialButtonLabel, EditorStyles.miniButtonRight, GUILayout.Width(46f))) { + } else if (allowDelete && GUILayout.Button(DeleteMaterialButtonLabel, EditorStyles.miniButtonRight, GUILayout.Width(46f))) { wasDeleteRequested = true; } if (!allowDelete) @@ -542,7 +541,7 @@ namespace Spine.Unity.Editor { } } - void HandleSkinChange() { + void HandleSkinChange () { if (!Application.isPlaying && Event.current.type == EventType.Layout && !initialSkinName.hasMultipleDifferentValues) { bool mismatchDetected = false; string newSkinName = initialSkinName.stringValue; @@ -574,9 +573,9 @@ namespace Spine.Unity.Editor { // solution or in a separate commit. The current solution does not repaint the Game view because // it is first applying values and in the next editor pass is calling this skin-changing method. if (skeletonRenderer is SkeletonAnimation) - ((SkeletonAnimation) skeletonRenderer).Update(0f); + ((SkeletonAnimation)skeletonRenderer).Update(0f); else if (skeletonRenderer is SkeletonMecanim) - ((SkeletonMecanim) skeletonRenderer).Update(); + ((SkeletonMecanim)skeletonRenderer).Update(); skeletonRenderer.LateUpdate(); return true; @@ -584,8 +583,8 @@ namespace Spine.Unity.Editor { return false; } - bool AreAnyMaskMaterialsMissing() { - #if BUILT_IN_SPRITE_MASK_COMPONENT + bool AreAnyMaskMaterialsMissing () { +#if BUILT_IN_SPRITE_MASK_COMPONENT foreach (var o in targets) { var component = (SkeletonRenderer)o; if (!component.valid) @@ -593,11 +592,11 @@ namespace Spine.Unity.Editor { if (SpineMaskUtilities.AreMaskMaterialsMissing(component)) return true; } - #endif +#endif return false; } - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT static void EditorSetMaskMaterials(SkeletonRenderer component, SpriteMaskInteraction maskType) { if (component == null) return; @@ -610,6 +609,6 @@ namespace Spine.Unity.Editor { if (!SpineEditorUtilities.SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return; SpineMaskUtilities.EditorDeleteMaskMaterials(component.maskMaterials, maskType); } - #endif +#endif } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs index b4e12b683..5603d016b 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityBoneInspector.cs @@ -33,10 +33,10 @@ #define HINGE_JOINT_NEW_BEHAVIOUR #endif -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; using Spine; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using Icons = SpineEditorUtilities.Icons; @@ -91,7 +91,7 @@ namespace Spine.Unity.Editor { if (skeleton.Skin == null) skin = skeleton.Data.DefaultSkin; - for(int i = 0; i < slotCount; i++){ + for (int i = 0; i < slotCount; i++) { Slot slot = skeletonUtility.Skeleton.Slots.Items[i]; if (slot.Bone == utilityBone.bone) { var slotAttachments = new List(); @@ -198,7 +198,7 @@ namespace Spine.Unity.Editor { using (new EditorGUI.DisabledGroupScope(multiObject || boundingBoxTable.Count == 0)) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Bounding Boxes", Icons.boundingBox), EditorStyles.boldLabel); - foreach (var entry in boundingBoxTable){ + foreach (var entry in boundingBoxTable) { Slot slot = entry.Key; var boundingBoxes = entry.Value; @@ -367,7 +367,7 @@ namespace Spine.Unity.Editor { } void ApplyJoint2DAngleLimits (HingeJoint2D joint, float rotationLimit, Transform parentBone, Transform bone) { - #if HINGE_JOINT_NEW_BEHAVIOUR +#if HINGE_JOINT_NEW_BEHAVIOUR float referenceAngle = (parentBone.eulerAngles.z - bone.eulerAngles.z + 360f) % 360f; float minAngle = referenceAngle - rotationLimit; float maxAngle = referenceAngle + rotationLimit; @@ -380,7 +380,7 @@ namespace Spine.Unity.Editor { maxAngle += 360f; } #else - float minAngle = - rotationLimit; + float minAngle = -rotationLimit; float maxAngle = rotationLimit; #endif joint.limits = new JointAngleLimits2D { @@ -432,7 +432,7 @@ namespace Spine.Unity.Editor { mirroredChain.SetActive(false); } - void FlipBone2DHorizontal(Transform bone, Transform mirrorPosition) { + void FlipBone2DHorizontal (Transform bone, Transform mirrorPosition) { Vector3 position = bone.position; position.x = 2 * mirrorPosition.position.x - position.x; // = mirrorPosition + (mirrorPosition - bone.position) bone.position = position; @@ -520,14 +520,13 @@ namespace Spine.Unity.Editor { utilBone.gameObject.AddComponent(); } - static void AttachRigidbodyAndCollider2D(SkeletonUtilityBone utilBone, bool enableCollider = false) { + static void AttachRigidbodyAndCollider2D (SkeletonUtilityBone utilBone, bool enableCollider = false) { if (utilBone.GetComponent() == null) { if (utilBone.bone.Data.Length == 0) { var sphere = utilBone.gameObject.AddComponent(); sphere.radius = 0.1f; sphere.enabled = enableCollider; - } - else { + } else { float length = utilBone.bone.Data.Length; var box = utilBone.gameObject.AddComponent(); box.size = new Vector3(length, length / 3f, 0.2f); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs index d20f00fbb..1447df8a0 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs @@ -31,12 +31,12 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; +using Spine; +using System.Collections.Generic; +using System.Reflection; using UnityEditor; using UnityEditor.AnimatedValues; -using System.Collections.Generic; -using Spine; -using System.Reflection; +using UnityEngine; namespace Spine.Unity.Editor { using Icons = SpineEditorUtilities.Icons; @@ -51,7 +51,7 @@ namespace Spine.Unity.Editor { #if !NEW_PREFAB_SYSTEM bool isPrefab; - #endif +#endif readonly GUIContent SpawnHierarchyButtonLabel = new GUIContent("Spawn Hierarchy", Icons.skeleton); @@ -65,8 +65,7 @@ namespace Spine.Unity.Editor { if (skeletonRenderer != null) { skeletonRenderer.Initialize(false); skeletonRenderer.LateUpdate(); - } - else if (skeletonGraphic != null) { + } else if (skeletonGraphic != null) { skeletonGraphic.Initialize(false); skeletonGraphic.LateUpdate(); } @@ -76,19 +75,19 @@ namespace Spine.Unity.Editor { if ((skeletonRenderer != null && !skeletonRenderer.valid) || (skeletonGraphic != null && !skeletonGraphic.IsValid)) return; - #if !NEW_PREFAB_SYSTEM +#if !NEW_PREFAB_SYSTEM isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab; - #endif +#endif } public override void OnInspectorGUI () { - #if !NEW_PREFAB_SYSTEM +#if !NEW_PREFAB_SYSTEM if (isPrefab) { GUILayout.Label(new GUIContent("Cannot edit Prefabs", Icons.warning)); return; } - #endif +#endif serializedObject.Update(); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineShaderWithOutlineGUI.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineShaderWithOutlineGUI.cs index 4b0d5824d..cdec1fca5 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineShaderWithOutlineGUI.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineShaderWithOutlineGUI.cs @@ -27,10 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using UnityEditor; using Spine.Unity; - +using UnityEditor; +using UnityEngine; using SpineInspectorUtility = Spine.Unity.Editor.SpineInspectorUtility; public class SpineShaderWithOutlineGUI : ShaderGUI { @@ -97,7 +96,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI { _StencilComp = FindProperty("_StencilComp", props, false); _StencilRef = FindProperty("_StencilRef", props, false); if (_StencilRef == null) - _StencilRef = FindProperty("_Stencil", props, false); + _StencilRef = FindProperty("_Stencil", props, false); } protected virtual void RenderStencilProperties () { @@ -141,8 +140,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI { SwitchShaderToOutlineSettings(material, isOutlineEnabled); } } - } - else { + } else { var origFontStyle = EditorStyles.label.fontStyle; EditorStyles.label.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField(_EnableOutlineText); @@ -178,8 +176,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI { shaderName = shaderName.Replace(ShaderOutlineNamePrefix, ShaderNormalNamePrefix); _materialEditor.SetShader(Shader.Find(shaderName), false); return; - } - else if (!isSetToOutlineShader && enableOutline) { + } else if (!isSetToOutlineShader && enableOutline) { shaderName = shaderName.Replace(ShaderNormalNamePrefix, ShaderOutlineNamePrefix); _materialEditor.SetShader(Shader.Find(shaderName), false); return; @@ -192,8 +189,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI { foreach (Material material in editor.targets) { if (material.shader.name.Contains(ShaderOutlineNamePrefix)) { isAnyEnabled = true; - } - else if (isAnyEnabled) { + } else if (isAnyEnabled) { mixedValue = true; } } @@ -206,8 +202,7 @@ public class SpineShaderWithOutlineGUI : ShaderGUI { foreach (Material material in editor.targets) { if (material.shader.name.Contains(ShaderWithoutStandardVariantSuffix)) { isAnyShaderWithoutVariant = true; - } - else if (isAnyShaderWithoutVariant) { + } else if (isAnyShaderWithoutVariant) { mixedValue = true; } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineSpriteShaderGUI.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineSpriteShaderGUI.cs index e7c534104..8f1c6a862 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineSpriteShaderGUI.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineSpriteShaderGUI.cs @@ -27,10 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using UnityEditor; using Spine.Unity; - +using UnityEditor; +using UnityEngine; using SpineInspectorUtility = Spine.Unity.Editor.SpineInspectorUtility; public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { @@ -528,17 +527,15 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { eBlendMode blendMode = GetMaterialBlendMode(material); switch (blendMode) { - case eBlendMode.Opaque: - { - SetRenderType(material, "Opaque", useCustomRenderType); - } - break; - default: - { - bool zWrite = HasZWriteEnabled(material); - SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderType); - } - break; + case eBlendMode.Opaque: { + SetRenderType(material, "Opaque", useCustomRenderType); + } + break; + default: { + bool zWrite = HasZWriteEnabled(material); + SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderType); + } + break; } } } @@ -942,14 +939,13 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { case eNormalsMode.FixedNormalsModelSpace: renderType = "SpriteModelSpaceFixedNormal"; break; - case eNormalsMode.MeshNormals: - { - //If sprite doesn't write to depth assign custom render type so we can write its depth with soft edges - if (!zWrite) { - renderType = "Sprite"; - } + case eNormalsMode.MeshNormals: { + //If sprite doesn't write to depth assign custom render type so we can write its depth with soft edges + if (!zWrite) { + renderType = "Sprite"; } - break; + } + break; } } @@ -1014,8 +1010,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { foreach (Material material in editor.targets) { if (material.shader.name == shaderType) { isAnyTargetTypeShader = true; - } - else if (isAnyTargetTypeShader) { + } else if (isAnyTargetTypeShader) { mixedValue = true; } } @@ -1040,21 +1035,16 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { if (material.shader.name == kShaderPixelLit || material.shader.name == kShaderPixelLitOutline) { return eLightMode.PixelLit; - } - else if (material.shader.name == kShaderUnlit || - material.shader.name == kShaderUnlitOutline) { + } else if (material.shader.name == kShaderUnlit || + material.shader.name == kShaderUnlitOutline) { return eLightMode.Unlit; - } - else if (material.shader.name == kShaderLitLW) { + } else if (material.shader.name == kShaderLitLW) { return eLightMode.LitLightweight; - } - else if (material.shader.name == kShaderLitURP) { + } else if (material.shader.name == kShaderLitURP) { return eLightMode.LitUniversal; - } - else if (material.shader.name == kShaderLitURP2D) { + } else if (material.shader.name == kShaderLitURP2D) { return eLightMode.LitUniversal2D; - } - else { // if (material.shader.name == kShaderVertexLit || kShaderVertexLitOutline) + } else { // if (material.shader.name == kShaderVertexLit || kShaderVertexLitOutline) return eLightMode.VertexLit; } } @@ -1091,59 +1081,53 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { bool useCustomRenderQueue = material.GetFloat("_CustomRenderQueue") > 0.0f; switch (blendMode) { - case eBlendMode.Opaque: - { - material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); - material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); - SetRenderType(material, "Opaque", useCustomRenderQueue); - renderQueue = kSolidQueue; - } - break; - case eBlendMode.Additive: - { - material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); - material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One); - bool zWrite = HasZWriteEnabled(material); - SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); - renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; - } - break; - case eBlendMode.SoftAdditive: - { - material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); - material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor); - bool zWrite = HasZWriteEnabled(material); - SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); - renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; - } - break; - case eBlendMode.Multiply: - { - material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero); - material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor); - bool zWrite = HasZWriteEnabled(material); - SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); - renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; - } - break; - case eBlendMode.Multiplyx2: - { - material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor); - material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor); - bool zWrite = HasZWriteEnabled(material); - SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); - renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; - } - break; - default: - { - material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); - material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - bool zWrite = HasZWriteEnabled(material); - SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); - renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; - } - break; + case eBlendMode.Opaque: { + material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); + material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); + SetRenderType(material, "Opaque", useCustomRenderQueue); + renderQueue = kSolidQueue; + } + break; + case eBlendMode.Additive: { + material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); + material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One); + bool zWrite = HasZWriteEnabled(material); + SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); + renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; + } + break; + case eBlendMode.SoftAdditive: { + material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); + material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor); + bool zWrite = HasZWriteEnabled(material); + SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); + renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; + } + break; + case eBlendMode.Multiply: { + material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero); + material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor); + bool zWrite = HasZWriteEnabled(material); + SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); + renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; + } + break; + case eBlendMode.Multiplyx2: { + material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor); + material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor); + bool zWrite = HasZWriteEnabled(material); + SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); + renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; + } + break; + default: { + material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); + material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); + bool zWrite = HasZWriteEnabled(material); + SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue); + renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue; + } + break; } material.renderQueue = renderQueue + material.GetInt("_RenderQueue"); @@ -1209,8 +1193,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI { static bool HasZWriteEnabled (Material material) { if (material.HasProperty("_ZWrite")) { return material.GetFloat("_ZWrite") > 0.0f; - } - else return true; // Pixel Lit shader always has _ZWrite enabled. + } else return true; // Pixel Lit shader always has _ZWrite enabled. } #endregion } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs index 33a928352..a834cddd9 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs @@ -29,13 +29,13 @@ // Contributed by: Mitch Thompson -using UnityEngine; -using UnityEditor; +using Spine; using System; using System.Collections.Generic; -using System.Reflection; -using Spine; using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { public struct SpineDrawerValuePair { @@ -48,7 +48,7 @@ namespace Spine.Unity.Editor { } } - public abstract class SpineTreeItemDrawerBase : PropertyDrawer where T:SpineAttributeBase { + public abstract class SpineTreeItemDrawerBase : PropertyDrawer where T : SpineAttributeBase { protected SkeletonDataAsset skeletonDataAsset; internal const string NoneStringConstant = ""; @@ -172,7 +172,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineSlot))] public class SpineSlotDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.slot; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.slot; } } protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) { if (TargetAttribute.includeNone) @@ -219,7 +219,7 @@ namespace Spine.Unity.Editor { public class SpineSkinDrawer : SpineTreeItemDrawerBase { const string DefaultSkinName = "default"; - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.skin; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.skin; } } internal override string NoneString { get { return TargetAttribute.defaultAsEmptyString ? DefaultSkinName : NoneStringConstant; } } @@ -267,7 +267,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineAnimation))] public class SpineAnimationDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.animation; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.animation; } } public static void GetAnimationMenuItems (SkeletonData data, List outputNames, List outputMenuItems, bool includeNone = true) { if (data == null) return; @@ -309,7 +309,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineEvent))] public class SpineEventNameDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.userEvent; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.userEvent; } } public static void GetEventMenuItems (SkeletonData data, List eventNames, List menuItems, bool includeNone = true) { if (data == null) return; @@ -354,7 +354,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineIkConstraint))] public class SpineIkConstraintDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintIK; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintIK; } } protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineIkConstraint targetAttribute, SkeletonData data) { var constraints = skeletonDataAsset.GetSkeletonData(false).IkConstraints; @@ -374,7 +374,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineTransformConstraint))] public class SpineTransformConstraintDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintTransform; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintTransform; } } protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineTransformConstraint targetAttribute, SkeletonData data) { var constraints = skeletonDataAsset.GetSkeletonData(false).TransformConstraints; @@ -393,7 +393,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpinePathConstraint))] public class SpinePathConstraintDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintPath; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintPath; } } protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpinePathConstraint targetAttribute, SkeletonData data) { var constraints = skeletonDataAsset.GetSkeletonData(false).PathConstraints; @@ -412,7 +412,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineAttachment))] public class SpineAttachmentDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.genericAttachment; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.genericAttachment; } } protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAttachment targetAttribute, SkeletonData data) { ISkeletonComponent skeletonComponent = GetTargetSkeletonComponent(property); @@ -514,7 +514,7 @@ namespace Spine.Unity.Editor { [CustomPropertyDrawer(typeof(SpineBone))] public class SpineBoneDrawer : SpineTreeItemDrawerBase { - protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.bone; } } + protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.bone; } } protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineBone targetAttribute, SkeletonData data) { menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name)); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index c79747a7f..c32e4fc8d 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -51,14 +51,13 @@ #define PROBLEMATIC_PACKAGE_ASSET_MODIFICATION #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; using System.IO; -using System.Text; using System.Linq; using System.Reflection; - +using System.Text; +using UnityEditor; +using UnityEngine; using CompatibilityProblemInfo = Spine.Unity.SkeletonDataCompatibility.CompatibilityProblemInfo; namespace Spine.Unity.Editor { @@ -115,7 +114,7 @@ namespace Spine.Unity.Editor { } } -#region Match SkeletonData with Atlases + #region Match SkeletonData with Atlases static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh }; public static List GetRequiredAtlasRegions (string skeletonDataPath) { @@ -132,15 +131,13 @@ namespace Spine.Unity.Editor { try { if (spineJson != null) { reader = new StringReader(spineJson.text); - } - else { + } else { // On a "Reimport All" the order of imports can be wrong, thus LoadAssetAtPath() above could return null. // as a workaround, we provide a fallback reader. reader = new StreamReader(skeletonDataPath); } root = Json.Deserialize(reader) as Dictionary; - } - finally { + } finally { if (reader != null) reader.Dispose(); } @@ -195,15 +192,13 @@ namespace Spine.Unity.Editor { try { if (data != null) { input = new MemoryStream(data.bytes); - } - else { + } else { // On a "Reimport All" the order of imports can be wrong, thus LoadAssetAtPath() above could return null. // as a workaround, we provide a fallback reader. input = File.Open(skeletonDataPath, FileMode.Open, FileAccess.Read); } binary.ReadSkeletonData(input); - } - finally { + } finally { if (input != null) input.Dispose(); } @@ -265,7 +260,7 @@ namespace Spine.Unity.Editor { return new ClippingAttachment(name); } } -#endregion + #endregion public static void ImportSpineContent (string[] imported, List texturesWithoutMetaFile, bool reimport = false) { @@ -278,49 +273,49 @@ namespace Spine.Unity.Editor { foreach (string str in imported) { string extension = Path.GetExtension(str).ToLower(); switch (extension) { - case ".atlas": - if (SpineEditorUtilities.Preferences.atlasTxtImportWarning) { - Debug.LogWarningFormat("`{0}` : If this file is a Spine atlas, please change its extension to `.atlas.txt`. This is to allow Unity to recognize it and avoid filename collisions. You can also set this file extension when exporting from the Spine editor.", str); - } - break; - case ".txt": - if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal)) - atlasPaths.Add(str); - break; - case ".png": - case ".jpg": - imagePaths.Add(str); - break; - case ".json": { - var jsonAsset = AssetDatabase.LoadAssetAtPath(str); + case ".atlas": + if (SpineEditorUtilities.Preferences.atlasTxtImportWarning) { + Debug.LogWarningFormat("`{0}` : If this file is a Spine atlas, please change its extension to `.atlas.txt`. This is to allow Unity to recognize it and avoid filename collisions. You can also set this file extension when exporting from the Spine editor.", str); + } + break; + case ".txt": + if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal)) + atlasPaths.Add(str); + break; + case ".png": + case ".jpg": + imagePaths.Add(str); + break; + case ".json": { + var jsonAsset = AssetDatabase.LoadAssetAtPath(str); + string problemDescription = null; + if (jsonAsset != null && IsSpineData(jsonAsset, out compatibilityProblemInfo, ref problemDescription)) + skeletonPaths.Add(new PathAndProblemInfo(str, compatibilityProblemInfo, problemDescription)); + if (problemDescription != null) + Debug.LogError(problemDescription, jsonAsset); + break; + } + case ".bytes": { + if (str.ToLower().EndsWith(".skel.bytes", System.StringComparison.Ordinal)) { + var binaryAsset = AssetDatabase.LoadAssetAtPath(str); string problemDescription = null; - if (jsonAsset != null && IsSpineData(jsonAsset, out compatibilityProblemInfo, ref problemDescription)) + if (IsSpineData(binaryAsset, out compatibilityProblemInfo, ref problemDescription)) skeletonPaths.Add(new PathAndProblemInfo(str, compatibilityProblemInfo, problemDescription)); if (problemDescription != null) - Debug.LogError(problemDescription, jsonAsset); - break; - } - case ".bytes": { - if (str.ToLower().EndsWith(".skel.bytes", System.StringComparison.Ordinal)) { - var binaryAsset = AssetDatabase.LoadAssetAtPath(str); - string problemDescription = null; - if (IsSpineData(binaryAsset, out compatibilityProblemInfo, ref problemDescription)) - skeletonPaths.Add(new PathAndProblemInfo(str, compatibilityProblemInfo, problemDescription)); - if (problemDescription != null) - Debug.LogError(problemDescription, binaryAsset); - } - break; + Debug.LogError(problemDescription, binaryAsset); } + break; + } } } // Import atlases first. var newAtlases = new List(); foreach (string ap in atlasPaths) { - #if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION +#if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION if (ap.StartsWith("Packages")) continue; - #endif +#endif TextAsset atlasText = AssetDatabase.LoadAssetAtPath(ap); AtlasAssetBase atlas = IngestSpineAtlas(atlasText, texturesWithoutMetaFile); newAtlases.Add(atlas); @@ -333,10 +328,10 @@ namespace Spine.Unity.Editor { string skeletonPath = skeletonPathEntry.path; var compatibilityProblems = skeletonPathEntry.compatibilityProblems; string otherProblemDescription = skeletonPathEntry.otherProblemDescription; - #if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION +#if PROBLEMATIC_PACKAGE_ASSET_MODIFICATION if (skeletonPath.StartsWith("Packages")) continue; - #endif +#endif if (!reimport && CheckForValidSkeletonData(skeletonPath)) { ReloadSkeletonData(skeletonPath, compatibilityProblems); continue; @@ -401,16 +396,16 @@ namespace Spine.Unity.Editor { } } - static void AddDependentSkeletonIfAtlasChanged(List skeletonPaths, List atlasPaths) { + static void AddDependentSkeletonIfAtlasChanged (List skeletonPaths, List atlasPaths) { foreach (var atlasPath in atlasPaths) { string skeletonPathJson = atlasPath.Replace(".atlas.txt", ".json"); - string skeletonPathBinary = atlasPath.Replace(".atlas.txt", ".skel.bytes"); + string skeletonPathBinary = atlasPath.Replace(".atlas.txt", ".skel.bytes"); string usedSkeletonPath = System.IO.File.Exists(skeletonPathJson) ? skeletonPathJson : System.IO.File.Exists(skeletonPathBinary) ? skeletonPathBinary : null; if (usedSkeletonPath == null) continue; - if (skeletonPaths.FindIndex(p => { return p.path == usedSkeletonPath; } ) < 0) { + if (skeletonPaths.FindIndex(p => { return p.path == usedSkeletonPath; }) < 0) { string problemDescription = null; CompatibilityProblemInfo compatibilityProblemInfo = null; TextAsset textAsset = AssetDatabase.LoadAssetAtPath(usedSkeletonPath); @@ -485,7 +480,7 @@ namespace Spine.Unity.Editor { } } -#region Import Atlases + #region Import Atlases static List FindAtlasesAtPath (string path) { List arr = new List(); DirectoryInfo dir = new DirectoryInfo(path); @@ -528,7 +523,7 @@ namespace Spine.Unity.Editor { atlasAsset.atlasFile = atlasText; List pageFiles = new List(); - Atlas atlas = atlasAsset.GetAtlas(onlyMetaData : true); + Atlas atlas = atlasAsset.GetAtlas(onlyMetaData: true); if (atlas != null) { foreach (var page in atlas.Pages) pageFiles.Add(page.name); @@ -679,8 +674,7 @@ namespace Spine.Unity.Editor { byte[] bytes = null; try { bytes = tempTexture.EncodeToPNG(); - } - catch (System.Exception) { + } catch (System.Exception) { // handled below } if (bytes == null || bytes.Length == 0) { @@ -747,8 +741,7 @@ namespace Spine.Unity.Editor { mat = new Material(Shader.Find(SpineEditorUtilities.Preferences.defaultShader)); ApplyPMAOrStraightAlphaSettings(mat, SpineEditorUtilities.Preferences.textureSettingsReference); AssetDatabase.CreateAsset(mat, materialPath); - } - else { + } else { vestigialMaterials.Remove(mat); } @@ -857,16 +850,16 @@ namespace Spine.Unity.Editor { MaterialChecks.EnablePMATextureAtMaterial(material, isUsingPMAWorkflow); } -#endregion + #endregion -#region Import SkeletonData (json or binary) - internal static string GetSkeletonDataAssetFilePath(TextAsset spineJson) { + #region Import SkeletonData (json or binary) + internal static string GetSkeletonDataAssetFilePath (TextAsset spineJson) { string primaryName = Path.GetFileNameWithoutExtension(spineJson.name); string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson)).Replace('\\', '/'); return assetPath + "/" + primaryName + SkeletonDataSuffix + ".asset"; } - internal static SkeletonDataAsset IngestIncompatibleSpineProject(TextAsset spineJson, + internal static SkeletonDataAsset IngestIncompatibleSpineProject (TextAsset spineJson, CompatibilityProblemInfo compatibilityProblemInfo) { if (spineJson == null) @@ -941,9 +934,9 @@ namespace Spine.Unity.Editor { } #endif } -#endregion + #endregion -#region Spine Skeleton Data File Validation + #region Spine Skeleton Data File Validation public static bool CheckForValidSkeletonData (string skeletonJSONPath) { string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/'); TextAsset textAsset = AssetDatabase.LoadAssetAtPath(skeletonJSONPath); @@ -966,9 +959,9 @@ namespace Spine.Unity.Editor { compatibilityProblemInfo = SkeletonDataCompatibility.GetCompatibilityProblemInfo(fileVersion); return isSpineSkeletonData; } -#endregion + #endregion -#region Dialogs + #region Dialogs public static void SkeletonImportDialog (string skeletonPath, List localAtlases, List requiredPaths, ref bool abortSkeletonImport) { bool resolved = false; while (!resolved) { @@ -981,36 +974,36 @@ namespace Spine.Unity.Editor { ); switch (result) { - case -1: - //Debug.Log("Select Atlas"); - AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath).Replace('\\', '/')); - if (selectedAtlas != null) { - localAtlases.Clear(); - localAtlases.Add(selectedAtlas); - var atlasMatch = AssetUtility.GetMatchingAtlas(requiredPaths, localAtlases); - if (atlasMatch != null) { - resolved = true; - AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath(skeletonPath), atlasMatch); - } + case -1: + //Debug.Log("Select Atlas"); + AtlasAssetBase selectedAtlas = BrowseAtlasDialog(Path.GetDirectoryName(skeletonPath).Replace('\\', '/')); + if (selectedAtlas != null) { + localAtlases.Clear(); + localAtlases.Add(selectedAtlas); + var atlasMatch = AssetUtility.GetMatchingAtlas(requiredPaths, localAtlases); + if (atlasMatch != null) { + resolved = true; + AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath(skeletonPath), atlasMatch); } - break; - case 0: // Resolve AtlasAssets... - var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath).Replace('\\', '/'), - Path.GetFileNameWithoutExtension(skeletonPath)); - if (atlasList != null) - AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath(skeletonPath), atlasList.ToArray()); + } + break; + case 0: // Resolve AtlasAssets... + var atlasList = MultiAtlasDialog(requiredPaths, Path.GetDirectoryName(skeletonPath).Replace('\\', '/'), + Path.GetFileNameWithoutExtension(skeletonPath)); + if (atlasList != null) + AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath(skeletonPath), atlasList.ToArray()); - resolved = true; - break; - case 1: // Import without atlas - Debug.LogWarning("Imported with missing atlases. Skeleton will not render: " + Path.GetFileName(skeletonPath)); - AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath(skeletonPath), new AtlasAssetBase[] { }); - resolved = true; - break; - case 2: // Stop importing all - abortSkeletonImport = true; - resolved = true; - break; + resolved = true; + break; + case 1: // Import without atlas + Debug.LogWarning("Imported with missing atlases. Skeleton will not render: " + Path.GetFileName(skeletonPath)); + AssetUtility.IngestSpineProject(AssetDatabase.LoadAssetAtPath(skeletonPath), new AtlasAssetBase[] { }); + resolved = true; + break; + case 2: // Stop importing all + abortSkeletonImport = true; + resolved = true; + break; } } } @@ -1069,29 +1062,29 @@ namespace Spine.Unity.Editor { ); switch (result) { - case 0: // Browse... - AtlasAssetBase selectedAtlasAsset = BrowseAtlasDialog(lastAtlasPath); - if (selectedAtlasAsset != null) { - if (!atlasAssets.Contains(selectedAtlasAsset)) { - var atlas = selectedAtlasAsset.GetAtlas(); - bool hasValidRegion = false; - foreach (string str in missingRegions) { - if (atlas.FindRegion(str) != null) { - hasValidRegion = true; - break; - } + case 0: // Browse... + AtlasAssetBase selectedAtlasAsset = BrowseAtlasDialog(lastAtlasPath); + if (selectedAtlasAsset != null) { + if (!atlasAssets.Contains(selectedAtlasAsset)) { + var atlas = selectedAtlasAsset.GetAtlas(); + bool hasValidRegion = false; + foreach (string str in missingRegions) { + if (atlas.FindRegion(str) != null) { + hasValidRegion = true; + break; } - atlasAssets.Add(selectedAtlasAsset); } + atlasAssets.Add(selectedAtlasAsset); } - break; - case 1: // Import anyway - resolved = true; - break; - case 2: // Cancel - atlasAssets = null; - resolved = true; - break; + } + break; + case 1: // Import anyway + resolved = true; + break; + case 2: // Cancel + atlasAssets = null; + resolved = true; + break; } } @@ -1114,7 +1107,7 @@ namespace Spine.Unity.Editor { return (AtlasAssetBase)obj; } -#endregion + #endregion public static string GetPathSafeName (string name) { foreach (char c in System.IO.Path.GetInvalidFileNameChars()) { // Doesn't handle more obscure file name limitations. @@ -1259,7 +1252,7 @@ namespace Spine.Unity.Editor { EditorGUIUtility.PingObject(Selection.activeObject); } -#region SkeletonMecanim + #region SkeletonMecanim #if SPINE_SKELETONMECANIM public static SkeletonMecanim InstantiateSkeletonMecanim (SkeletonDataAsset skeletonDataAsset, string skinName) { return InstantiateSkeletonMecanim(skeletonDataAsset, skeletonDataAsset.GetSkeletonData(true).FindSkin(skinName)); @@ -1315,6 +1308,6 @@ namespace Spine.Unity.Editor { return newSkeletonMecanim; } #endif -#endregion + #endregion } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs index efa2baa83..e2e3b2cb2 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs @@ -30,11 +30,11 @@ // from spine-unity 4.0 onward BlendModeMaterialAssets are obsolete and shall be upgraded. #define UPGRADE_ALL_BLEND_MODE_MATERIALS -using UnityEngine; -using UnityEditor; +using System; using System.Collections.Generic; using System.IO; -using System; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { @@ -82,11 +82,9 @@ namespace Spine.Unity.Editor { TransferSettingsFromModifierAsset(blendModesModifierAsset, skeletonDataAsset, templateMaterials); UpdateBlendmodeMaterialsRequiredState(skeletonDataAsset, skeletonData); - } - else + } else return; - } - else { + } else { if (!UpdateBlendmodeMaterialsRequiredState(skeletonDataAsset, skeletonData)) return; AssignPreferencesTemplateMaterials(templateMaterials); @@ -112,8 +110,7 @@ namespace Spine.Unity.Editor { if (!skeletonDataAsset.blendModeMaterials.applyAdditiveMaterial) { anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.additiveMaterials.Count > 0; skeletonDataAsset.blendModeMaterials.additiveMaterials.Clear(); - } - else + } else anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.additiveMaterials.RemoveAll(ifMaterialMissing) != 0; anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.multiplyMaterials.RemoveAll(ifMaterialMissing) != 0; anyMaterialsChanged |= skeletonDataAsset.blendModeMaterials.screenMaterials.RemoveAll(ifMaterialMissing) != 0; @@ -181,21 +178,21 @@ namespace Spine.Unity.Editor { Material materialTemplate = null; string materialSuffix = null; switch (slot.BlendMode) { - case BlendMode.Multiply: - replacementMaterials = blendModeMaterials.multiplyMaterials; - materialTemplate = templateMaterials.multiplyTemplate; - materialSuffix = MATERIAL_SUFFIX_MULTIPLY; - break; - case BlendMode.Screen: - replacementMaterials = blendModeMaterials.screenMaterials; - materialTemplate = templateMaterials.screenTemplate; - materialSuffix = MATERIAL_SUFFIX_SCREEN; - break; - case BlendMode.Additive: - replacementMaterials = blendModeMaterials.additiveMaterials; - materialTemplate = templateMaterials.additiveTemplate; - materialSuffix = MATERIAL_SUFFIX_ADDITIVE; - break; + case BlendMode.Multiply: + replacementMaterials = blendModeMaterials.multiplyMaterials; + materialTemplate = templateMaterials.multiplyTemplate; + materialSuffix = MATERIAL_SUFFIX_MULTIPLY; + break; + case BlendMode.Screen: + replacementMaterials = blendModeMaterials.screenMaterials; + materialTemplate = templateMaterials.screenTemplate; + materialSuffix = MATERIAL_SUFFIX_SCREEN; + break; + case BlendMode.Additive: + replacementMaterials = blendModeMaterials.additiveMaterials; + materialTemplate = templateMaterials.additiveTemplate; + materialSuffix = MATERIAL_SUFFIX_ADDITIVE; + break; } skinEntries.Clear(); @@ -218,9 +215,8 @@ namespace Spine.Unity.Editor { Debug.Log(string.Format("Created blend mode Material '{0}' for SkeletonDataAsset '{1}'.", replacement.material.name, skeletonDataAsset), replacement.material); } - } - else { - Debug.LogError(string.Format("Failed creating blend mode Material for SkeletonDataAsset '{0}',"+ + } else { + Debug.LogError(string.Format("Failed creating blend mode Material for SkeletonDataAsset '{0}'," + " atlas page '{1}', template '{2}'.", skeletonDataAsset.name, originalRegion.page.name, materialTemplate.name), skeletonDataAsset); @@ -236,7 +232,7 @@ namespace Spine.Unity.Editor { return !anyCreationFailed; } - protected static string GetBlendModeMaterialPath(AtlasPage originalPage, string materialSuffix) { + protected static string GetBlendModeMaterialPath (AtlasPage originalPage, string materialSuffix) { var originalMaterial = originalPage.rendererObject as Material; var originalPath = AssetDatabase.GetAssetPath(originalMaterial); return originalPath.Replace(".mat", materialSuffix + ".mat"); @@ -254,8 +250,7 @@ namespace Spine.Unity.Editor { newReplacement.pageName = originalPage.name; if (File.Exists(blendMaterialPath)) { newReplacement.material = AssetDatabase.LoadAssetAtPath(blendMaterialPath); - } - else { + } else { var blendModeMaterial = new Material(materialTemplate) { name = originalMaterial.name + " " + materialTemplate.name, mainTexture = originalMaterial.mainTexture diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BuildSettings.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BuildSettings.cs index b3a2156aa..4b16cfcc9 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BuildSettings.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BuildSettings.cs @@ -43,14 +43,14 @@ #define NEWHIERARCHYWINDOWCALLBACKS #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { public partial class SpineEditorUtilities { @@ -82,8 +82,7 @@ namespace Spine.Unity.Editor { } } - public static class SpineBuildEnvUtility - { + public static class SpineBuildEnvUtility { static bool IsInvalidGroup (BuildTargetGroup group) { int gi = (int)group; return @@ -115,8 +114,7 @@ namespace Spine.Unity.Editor { if (wasDefineAdded) { Debug.LogWarning("Setting Scripting Define Symbol " + define); - } - else { + } else { Debug.LogWarning("Already Set Scripting Define Symbol " + define); } return wasDefineAdded; @@ -143,8 +141,7 @@ namespace Spine.Unity.Editor { if (wasDefineRemoved) { Debug.LogWarning("Removing Scripting Define Symbol " + define); - } - else { + } else { Debug.LogWarning("Already Removed Scripting Define Symbol " + define); } return wasDefineRemoved; diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs index e14c0dbff..6e802ada9 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs @@ -35,14 +35,14 @@ #define NEWPLAYMODECALLBACKS #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { @@ -51,11 +51,11 @@ namespace Spine.Unity.Editor { internal static Dictionary savedSkeletonDataAssetAtSKeletonGraphicID = new Dictionary(); - #if NEWPLAYMODECALLBACKS +#if NEWPLAYMODECALLBACKS internal static void OnPlaymodeStateChanged (PlayModeStateChange stateChange) { - #else +#else internal static void OnPlaymodeStateChanged () { - #endif +#endif ReloadAllActiveSkeletonsEditMode(); } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs index 71e7ce15c..1bd816472 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Icons.cs @@ -31,14 +31,14 @@ #define SPINE_SKELETONMECANIM -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { public partial class SpineEditorUtilities { diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Instantiation.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Instantiation.cs index d76a7709d..79a319238 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Instantiation.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Instantiation.cs @@ -31,14 +31,14 @@ #define SPINE_SKELETONMECANIM -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using EventType = UnityEngine.EventType; @@ -155,8 +155,7 @@ namespace Spine.Unity.Editor { if (isUI) { if (usedParent != null && usedParent.GetComponent() != null) { ((SkeletonGraphic)newSkeletonComponent).MatchRectTransformWithBounds(); - } - else + } else Debug.Log("Created a UI Skeleton GameObject not under a RectTransform. It may not be visible until you parent it to a canvas."); } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs index def876116..f17603cf2 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/Preferences.cs @@ -43,19 +43,19 @@ #define NEW_PREFERENCES_SETTINGS_PROVIDER #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { public partial class SpineEditorUtilities { - #if NEW_PREFERENCES_SETTINGS_PROVIDER +#if NEW_PREFERENCES_SETTINGS_PROVIDER static class SpineSettingsProviderRegistration { [SettingsProvider] @@ -79,27 +79,27 @@ namespace Spine.Unity.Editor { return provider; } } - #else +#else // Preferences entry point [PreferenceItem("Spine")] static void PreferencesGUI () { Preferences.HandlePreferencesGUI(); } - #endif +#endif - #if NEW_PREFERENCES_SETTINGS_PROVIDER +#if NEW_PREFERENCES_SETTINGS_PROVIDER public static SpinePreferences Preferences { get { return SpinePreferences.GetOrCreateSettings(); } } - #endif +#endif - #if NEW_PREFERENCES_SETTINGS_PROVIDER +#if NEW_PREFERENCES_SETTINGS_PROVIDER public static class OldPreferences { - #else +#else public static class Preferences { - #endif +#endif const string DEFAULT_SCALE_KEY = "SPINE_DEFAULT_SCALE"; public static float defaultScale = SpinePreferences.DEFAULT_DEFAULT_SCALE; @@ -423,12 +423,12 @@ namespace Spine.Unity.Editor { property.stringValue = material ? AssetDatabase.GetAssetPath(material) : ""; } - #if NEW_PREFERENCES_SETTINGS_PROVIDER +#if NEW_PREFERENCES_SETTINGS_PROVIDER public static void PresetAssetPropertyField (SerializedProperty property, GUIContent label) { var texturePreset = (EditorGUILayout.ObjectField(label, AssetDatabase.LoadAssetAtPath(property.stringValue), typeof(UnityEditor.Presets.Preset), false) as UnityEditor.Presets.Preset); bool isTexturePreset = texturePreset != null && texturePreset.GetTargetTypeName() == "TextureImporter"; property.stringValue = isTexturePreset ? AssetDatabase.GetAssetPath(texturePreset) : ""; } - #endif +#endif } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs index 47972c356..66ed31e9e 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs @@ -36,25 +36,23 @@ #define HAS_ON_POSTPROCESS_PREFAB #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using UnityEditor; using UnityEditor.Build; +using UnityEngine; #if HAS_BUILD_PROCESS_WITH_REPORT using UnityEditor.Build.Reporting; #endif namespace Spine.Unity.Editor { - public class SpineBuildProcessor - { + public class SpineBuildProcessor { internal static bool isBuilding = false; #if HAS_ON_POSTPROCESS_PREFAB static List prefabsToRestore = new List(); #endif - internal static void PreprocessBuild() - { + internal static void PreprocessBuild () { isBuilding = true; #if HAS_ON_POSTPROCESS_PREFAB var assets = AssetDatabase.FindAssets("t:Prefab"); @@ -69,8 +67,7 @@ namespace Spine.Unity.Editor { #endif } - internal static void PostprocessBuild() - { + internal static void PostprocessBuild () { isBuilding = false; #if HAS_ON_POSTPROCESS_PREFAB foreach (string assetPath in prefabsToRestore) { @@ -98,8 +95,7 @@ namespace Spine.Unity.Editor { SpineBuildProcessor.PreprocessBuild(); } #else - void IPreprocessBuild.OnPreprocessBuild(BuildTarget target, string path) - { + void IPreprocessBuild.OnPreprocessBuild (BuildTarget target, string path) { SpineBuildProcessor.PreprocessBuild(); } #endif @@ -123,8 +119,7 @@ namespace Spine.Unity.Editor { SpineBuildProcessor.PostprocessBuild(); } #else - void IPostprocessBuild.OnPostprocessBuild(BuildTarget target, string path) - { + void IPostprocessBuild.OnPostprocessBuild (BuildTarget target, string path) { SpineBuildProcessor.PostprocessBuild(); } #endif diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs index 889f382ed..6b6a01b18 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs @@ -54,14 +54,14 @@ #define HAS_ON_POSTPROCESS_PREFAB #endif -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using EventType = UnityEngine.EventType; @@ -77,11 +77,11 @@ namespace Spine.Unity.Editor { // Auto-import entry point for textures void OnPreprocessTexture () { - #if UNITY_2018_1_OR_NEWER +#if UNITY_2018_1_OR_NEWER bool customTextureSettingsExist = !assetImporter.importSettingsMissing; - #else +#else bool customTextureSettingsExist = System.IO.File.Exists(assetImporter.assetPath + ".meta"); - #endif +#endif if (!customTextureSettingsExist) { texturesWithoutMetaFile.Add(assetImporter.assetPath); } @@ -159,11 +159,11 @@ namespace Spine.Unity.Editor { static void Initialize () { // Note: Preferences need to be loaded when changing play mode // to initialize handle scale correctly. - #if !NEW_PREFERENCES_SETTINGS_PROVIDER +#if !NEW_PREFERENCES_SETTINGS_PROVIDER Preferences.Load(); - #else +#else SpinePreferences.Load(); - #endif +#endif if (EditorApplication.isPlayingOrWillChangePlaymode) return; @@ -175,46 +175,45 @@ namespace Spine.Unity.Editor { if (assets.Length > 0) { assetPath = AssetDatabase.GUIDToAssetPath(assets[0]); editorGUIPath = Path.GetDirectoryName(assetPath).Replace('\\', '/'); - } - else { + } else { editorGUIPath = editorPath.Replace("/Utility", "/GUI"); } Icons.Initialize(); // Drag and Drop - #if UNITY_2019_1_OR_NEWER +#if UNITY_2019_1_OR_NEWER SceneView.duringSceneGui -= DragAndDropInstantiation.SceneViewDragAndDrop; SceneView.duringSceneGui += DragAndDropInstantiation.SceneViewDragAndDrop; - #else +#else SceneView.onSceneGUIDelegate -= DragAndDropInstantiation.SceneViewDragAndDrop; SceneView.onSceneGUIDelegate += DragAndDropInstantiation.SceneViewDragAndDrop; - #endif +#endif EditorApplication.hierarchyWindowItemOnGUI -= HierarchyHandler.HandleDragAndDrop; EditorApplication.hierarchyWindowItemOnGUI += HierarchyHandler.HandleDragAndDrop; // Hierarchy Icons - #if NEWPLAYMODECALLBACKS +#if NEWPLAYMODECALLBACKS EditorApplication.playModeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged; EditorApplication.playModeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged; HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode); - #else +#else EditorApplication.playmodeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged; EditorApplication.playmodeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged; HierarchyHandler.IconsOnPlaymodeStateChanged(); - #endif +#endif // Data Refresh Edit Mode. // This prevents deserialized SkeletonData from persisting from play mode to edit mode. - #if NEWPLAYMODECALLBACKS +#if NEWPLAYMODECALLBACKS EditorApplication.playModeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged; EditorApplication.playModeStateChanged += DataReloadHandler.OnPlaymodeStateChanged; DataReloadHandler.OnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode); - #else +#else EditorApplication.playmodeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged; EditorApplication.playmodeStateChanged += DataReloadHandler.OnPlaymodeStateChanged; DataReloadHandler.OnPlaymodeStateChanged(); - #endif +#endif if (SpineEditorUtilities.Preferences.textureImporterWarning) { IssueWarningsForUnrecommendedTextureSettings(); @@ -228,7 +227,7 @@ namespace Spine.Unity.Editor { Initialize(); } - public static void IssueWarningsForUnrecommendedTextureSettings() { + public static void IssueWarningsForUnrecommendedTextureSettings () { string[] atlasDescriptionGUIDs = AssetDatabase.FindAssets("t:textasset .atlas"); // Note: finds ".atlas.txt" but also ".atlas 1.txt" files. for (int i = 0; i < atlasDescriptionGUIDs.Length; ++i) { @@ -288,9 +287,9 @@ namespace Spine.Unity.Editor { stateComponent.AnimationState.AssignEventSubscribersFrom(oldAnimationState); } - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT SpineMaskUtilities.EditorAssignSpriteMaskMaterials(component); - #endif +#endif component.LateUpdate(); } @@ -305,8 +304,7 @@ namespace Spine.Unity.Editor { return asset != null && asset.GetSkeletonData(quiet: true) != null; } - public static bool IssueWarningsForUnrecommendedTextureSettings(string texturePath) - { + public static bool IssueWarningsForUnrecommendedTextureSettings (string texturePath) { TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath); if (texImporter == null) { return false; @@ -321,7 +319,7 @@ namespace Spine.Unity.Editor { string errorMessage = null; if (MaterialChecks.IsTextureSetupProblematic(material, PlayerSettings.colorSpace, - texImporter. sRGBTexture, texImporter. mipmapEnabled, texImporter. alphaIsTransparency, + texImporter.sRGBTexture, texImporter.mipmapEnabled, texImporter.alphaIsTransparency, texturePath, materialPath, ref errorMessage)) { Debug.LogWarning(errorMessage, material); } @@ -492,10 +490,8 @@ namespace Spine.Unity.Editor { } } - public class TextureModificationWarningProcessor : UnityEditor.AssetModificationProcessor - { - static string[] OnWillSaveAssets(string[] paths) - { + public class TextureModificationWarningProcessor : UnityEditor.AssetModificationProcessor { + static string[] OnWillSaveAssets (string[] paths) { if (SpineEditorUtilities.Preferences.textureImporterWarning) { foreach (string path in paths) { if ((path != null) && diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs index f2b69a7fc..8ead2d4c7 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineHandles.cs @@ -31,23 +31,23 @@ #define SPINE_SKELETONMECANIM -using UnityEngine; -using UnityEditor; using System.Collections.Generic; +using System.Globalization; using System.IO; -using System.Text; using System.Linq; using System.Reflection; -using System.Globalization; +using System.Text; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { using EventType = UnityEngine.EventType; public static class SpineHandles { public static Color BoneColor { get { return new Color(0.8f, 0.8f, 0.8f, 0.4f); } } - public static Color PathColor { get { return new Color(254/255f, 127/255f, 0); } } - public static Color TransformContraintColor { get { return new Color(170/255f, 226/255f, 35/255f); } } - public static Color IkColor { get { return new Color(228/255f,90/255f,43/255f); } } + public static Color PathColor { get { return new Color(254 / 255f, 127 / 255f, 0); } } + public static Color TransformContraintColor { get { return new Color(170 / 255f, 226 / 255f, 35 / 255f); } } + public static Color IkColor { get { return new Color(228 / 255f, 90 / 255f, 43 / 255f); } } public static Color PointColor { get { return new Color(1f, 1f, 0f, 1f); } } static Vector3[] _boneMeshVerts = { @@ -63,7 +63,7 @@ namespace Spine.Unity.Editor { _boneMesh = new Mesh { vertices = _boneMeshVerts, uv = new Vector2[4], - triangles = new [] { 0, 1, 2, 2, 3, 0 } + triangles = new[] { 0, 1, 2, 2, 3, 0 } }; _boneMesh.RecalculateBounds(); _boneMesh.RecalculateNormals(); @@ -77,13 +77,13 @@ namespace Spine.Unity.Editor { get { if (_arrowheadMesh == null) { _arrowheadMesh = new Mesh { - vertices = new [] { + vertices = new[] { new Vector3(0, 0), new Vector3(-0.1f, 0.05f), new Vector3(-0.1f, -0.05f) }, uv = new Vector2[3], - triangles = new [] { 0, 1, 2 } + triangles = new[] { 0, 1, 2 } }; _arrowheadMesh.RecalculateBounds(); _arrowheadMesh.RecalculateNormals(); @@ -269,10 +269,10 @@ namespace Spine.Unity.Editor { int n = worldVerticesLength - step; Vector3 p0, p1, p2, p3; for (int i = 2; i < n; i += step) { - p0 = m.MultiplyPoint(new Vector3(pv[i], pv[i+1])); - p1 = m.MultiplyPoint(new Vector3(pv[i+2], pv[i+3])); - p2 = m.MultiplyPoint(new Vector3(pv[i+4], pv[i+5])); - p3 = m.MultiplyPoint(new Vector3(pv[i+6], pv[i+7])); + p0 = m.MultiplyPoint(new Vector3(pv[i], pv[i + 1])); + p1 = m.MultiplyPoint(new Vector3(pv[i + 2], pv[i + 3])); + p2 = m.MultiplyPoint(new Vector3(pv[i + 4], pv[i + 5])); + p3 = m.MultiplyPoint(new Vector3(pv[i + 6], pv[i + 7])); DrawCubicBezier(p0, p1, p2, p3); } @@ -290,7 +290,7 @@ namespace Spine.Unity.Editor { SpineHandles.DrawDot(firstPoint, endCapSize); //if (!p.Closed) SpineHandles.DrawDot(m.MultiplyPoint(new Vector3(pv[n - 4], pv[n - 3])), endCapSize); - if (includeName) Handles.Label(firstPoint + new Vector3(0,0.1f), p.Name, PathNameStyle); + if (includeName) Handles.Label(firstPoint + new Vector3(0, 0.1f), p.Name, PathNameStyle); Handles.color = ocolor; } @@ -385,30 +385,30 @@ namespace Spine.Unity.Editor { pos = bones.Items[0].GetWorldPosition(transform, skeletonRenderScale); switch (bones.Count) { case 1: { - Handles.color = handleColor; - Handles.DrawLine(targetPos, pos); - SpineHandles.DrawBoneCircle(targetPos, handleColor, normal); - var m = bones.Items[0].GetMatrix4x4(); - m.m03 = targetBone.WorldX * skeletonRenderScale; - m.m13 = targetBone.WorldY * skeletonRenderScale; - SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m); - break; - } + Handles.color = handleColor; + Handles.DrawLine(targetPos, pos); + SpineHandles.DrawBoneCircle(targetPos, handleColor, normal); + var m = bones.Items[0].GetMatrix4x4(); + m.m03 = targetBone.WorldX * skeletonRenderScale; + m.m13 = targetBone.WorldY * skeletonRenderScale; + SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m); + break; + } case 2: { - Bone childBone = bones.Items[1]; - Vector3 child = childBone.GetWorldPosition(transform, skeletonRenderScale); - Handles.color = handleColor; - Handles.DrawLine(child, pos); - Handles.DrawLine(targetPos, child); - SpineHandles.DrawBoneCircle(pos, handleColor, normal, 0.5f); - SpineHandles.DrawBoneCircle(child, handleColor, normal, 0.5f); - SpineHandles.DrawBoneCircle(targetPos, handleColor, normal); - var m = childBone.GetMatrix4x4(); - m.m03 = targetBone.WorldX * skeletonRenderScale; - m.m13 = targetBone.WorldY * skeletonRenderScale; - SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m); - break; - } + Bone childBone = bones.Items[1]; + Vector3 child = childBone.GetWorldPosition(transform, skeletonRenderScale); + Handles.color = handleColor; + Handles.DrawLine(child, pos); + Handles.DrawLine(targetPos, child); + SpineHandles.DrawBoneCircle(pos, handleColor, normal, 0.5f); + SpineHandles.DrawBoneCircle(child, handleColor, normal, 0.5f); + SpineHandles.DrawBoneCircle(targetPos, handleColor, normal); + var m = childBone.GetMatrix4x4(); + m.m03 = targetBone.WorldX * skeletonRenderScale; + m.m13 = targetBone.WorldY * skeletonRenderScale; + SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m); + break; + } } } //Handles.Label(targetPos, ikc.Data.Name, SpineHandles.BoneNameStyle); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineInspectorUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineInspectorUtility.cs index 7842686c1..78376b9ea 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineInspectorUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineInspectorUtility.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using UnityEditor; using System.Collections.Generic; using System.Reflection; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { public static class SpineInspectorUtility { @@ -108,11 +108,11 @@ namespace Spine.Unity.Editor { return current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed"; } - public static Texture2D UnityIcon() { + public static Texture2D UnityIcon () { return EditorGUIUtility.ObjectContent(null, typeof(T)).image as Texture2D; } - public static Texture2D UnityIcon(System.Type type) { + public static Texture2D UnityIcon (System.Type type) { return EditorGUIUtility.ObjectContent(null, type).image as Texture2D; } @@ -325,7 +325,7 @@ namespace Spine.Unity.Editor { static MethodInfo SortingLayerFieldMethod { get { if (m_SortingLayerFieldMethod == null) - m_SortingLayerFieldMethod = typeof(EditorGUILayout).GetMethod("SortingLayerField", BindingFlags.Static | BindingFlags.NonPublic, null, new [] { typeof(GUIContent), typeof(SerializedProperty), typeof(GUIStyle) }, null); + m_SortingLayerFieldMethod = typeof(EditorGUILayout).GetMethod("SortingLayerField", BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(GUIContent), typeof(SerializedProperty), typeof(GUIStyle) }, null); return m_SortingLayerFieldMethod; } @@ -336,8 +336,8 @@ namespace Spine.Unity.Editor { public SerializedProperty sortingLayerID; public SerializedProperty sortingOrder; - public SerializedSortingProperties (Renderer r) : this(new SerializedObject(r)) {} - public SerializedSortingProperties (Object[] renderers) : this(new SerializedObject(renderers)) {} + public SerializedSortingProperties (Renderer r) : this(new SerializedObject(r)) { } + public SerializedSortingProperties (Object[] renderers) : this(new SerializedObject(renderers)) { } public SerializedSortingProperties (SerializedObject rendererSerializedObject) { renderer = rendererSerializedObject; @@ -362,7 +362,7 @@ namespace Spine.Unity.Editor { EditorGUI.BeginChangeCheck(); if (SpineInspectorUtility.SortingLayerFieldMethod != null && prop.sortingLayerID != null) - SpineInspectorUtility.SortingLayerFieldMethod.Invoke(null, new object[] { SortingLayerLabel, prop.sortingLayerID, EditorStyles.popup } ); + SpineInspectorUtility.SortingLayerFieldMethod.Invoke(null, new object[] { SortingLayerLabel, prop.sortingLayerID, EditorStyles.popup }); else EditorGUILayout.PropertyField(prop.sortingLayerID); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs index a4bf07057..88e0b826c 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs @@ -33,15 +33,15 @@ #define SPINE_SKELETONMECANIM -using UnityEngine; -using UnityEditor; -using UnityEditorInternal; +using Spine; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; -using System.IO; -using Spine; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; namespace Spine.Unity.Editor { @@ -72,7 +72,7 @@ namespace Spine.Unity.Editor { public static class SkeletonBaker { #region SkeletonMecanim's Mecanim Clips - #if SPINE_SKELETONMECANIM +#if SPINE_SKELETONMECANIM public static void UpdateMecanimClips (SkeletonDataAsset skeletonDataAsset) { if (skeletonDataAsset.controller == null) return; @@ -170,7 +170,7 @@ namespace Spine.Unity.Editor { static bool HasFlag (this UnityEngine.Object o, HideFlags flagToCheck) { return (o.hideFlags & flagToCheck) == flagToCheck; } - #endif +#endif #endregion #region Prefab and AnimationClip Baking @@ -279,13 +279,13 @@ namespace Spine.Unity.Editor { Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)); if (prefab == null) { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM GameObject emptyGameObject = new GameObject(); prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(emptyGameObject, prefabPath, InteractionMode.AutomatedAction); GameObject.DestroyImmediate(emptyGameObject); - #else +#else prefab = PrefabUtility.CreateEmptyPrefab(prefabPath); - #endif +#endif newPrefab = true; } @@ -432,22 +432,22 @@ namespace Spine.Unity.Editor { } if (newPrefab) { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM PrefabUtility.SaveAsPrefabAssetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction); - #else +#else PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab); - #endif +#endif } else { foreach (string str in unusedMeshNames) { Mesh.DestroyImmediate(meshTable[str], true); } - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM PrefabUtility.SaveAsPrefabAssetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction); - #else +#else PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased); - #endif +#endif } @@ -532,7 +532,7 @@ namespace Spine.Unity.Editor { mesh.vertices = verts; mesh.uv = uvs; mesh.triangles = triangles; - mesh.colors = new [] { color, color, color, color }; + mesh.colors = new[] { color, color, color, color }; mesh.RecalculateBounds(); mesh.RecalculateNormals(); mesh.name = name; @@ -740,9 +740,9 @@ namespace Spine.Unity.Editor { return arr; } -#endregion + #endregion -#region Animation Baking + #region Animation Baking static AnimationClip ExtractAnimation (string name, SkeletonData skeletonData, Dictionary> slotLookup, bool bakeIK, SendMessageOptions eventOptions, AnimationClip clip = null) { var animation = skeletonData.FindAnimation(name); @@ -1416,10 +1416,10 @@ namespace Spine.Unity.Editor { return angle; } -#endregion -#endregion + #endregion + #endregion -#region Region Baking + #region Region Baking public static GameObject BakeRegion (SpineAtlasAsset atlasAsset, AtlasRegion region, bool autoSave = true) { atlasAsset.GetAtlas(); // Initializes atlasAsset. @@ -1438,11 +1438,11 @@ namespace Spine.Unity.Editor { if (prefab == null) { root = EditorInstantiation.NewGameObject("temp", true, typeof(MeshFilter), typeof(MeshRenderer)); - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM prefab = PrefabUtility.SaveAsPrefabAsset(root, bakedPrefabPath); - #else +#else prefab = PrefabUtility.CreatePrefab(bakedPrefabPath, root); - #endif +#endif isNewPrefab = true; Object.DestroyImmediate(root); @@ -1469,7 +1469,7 @@ namespace Spine.Unity.Editor { return prefab; } -#endregion + #endregion static string GetPath (BoneData b) { return GetPathRecurse(b).Substring(1); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBakingWindow.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBakingWindow.cs index 62870d00d..4b1246749 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBakingWindow.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBakingWindow.cs @@ -29,8 +29,8 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { @@ -51,7 +51,7 @@ namespace Spine.Unity.Editor { } public SkeletonDataAsset skeletonDataAsset; - [SpineSkin(dataField:"skeletonDataAsset")] + [SpineSkin(dataField: "skeletonDataAsset")] public string skinToBake = "default"; // Settings diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonDebugWindow.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonDebugWindow.cs index 011c6f013..045cd253a 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonDebugWindow.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonDebugWindow.cs @@ -36,9 +36,9 @@ #endif using System.Collections.Generic; -using UnityEngine; using UnityEditor; using UnityEditor.AnimatedValues; +using UnityEngine; namespace Spine.Unity.Editor { using Editor = UnityEditor.Editor; @@ -81,7 +81,7 @@ namespace Spine.Unity.Editor { SerializedProperty bpo; Bone bone; - [SpineBone(dataField:"skeletonRenderer")] + [SpineBone(dataField: "skeletonRenderer")] public string boneName; readonly Dictionary> attachmentTable = new Dictionary>(); @@ -105,13 +105,13 @@ namespace Spine.Unity.Editor { } void OnSelectionChange () { - #if UNITY_2019_1_OR_NEWER +#if UNITY_2019_1_OR_NEWER SceneView.duringSceneGui -= this.OnSceneGUI; SceneView.duringSceneGui += this.OnSceneGUI; - #else +#else SceneView.onSceneGUIDelegate -= this.OnSceneGUI; SceneView.onSceneGUIDelegate += this.OnSceneGUI; - #endif +#endif bool noSkeletonRenderer = false; @@ -152,11 +152,11 @@ namespace Spine.Unity.Editor { isPrefab = false; boneName = string.Empty; bone = null; - #if UNITY_2019_1_OR_NEWER +#if UNITY_2019_1_OR_NEWER SceneView.duringSceneGui -= this.OnSceneGUI; - #else +#else SceneView.onSceneGUIDelegate -= this.OnSceneGUI; - #endif +#endif } void OnDestroy () { @@ -484,7 +484,7 @@ namespace Spine.Unity.Editor { if (Application.isPlaying) { foreach (var slot in skeleton.DrawOrder) { - if (skeletonRenderer.separatorSlots.Contains(slot)) EditorGUILayout.LabelField(SeparatorString); + if (skeletonRenderer.separatorSlots.Contains(slot)) EditorGUILayout.LabelField(SeparatorString); using (new EditorGUI.DisabledScope(!slot.Bone.Active)) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(slot.Data.Name, Icons.slot), GUILayout.ExpandWidth(false)); @@ -557,13 +557,13 @@ namespace Spine.Unity.Editor { static float ViewRound (float x) { const float Factor = 100f; - const float Divisor = 1f/Factor; + const float Divisor = 1f / Factor; return Mathf.Round(x * Factor) * Divisor; } static Vector2 RoundVector2 (float x, float y) { const float Factor = 100f; - const float Divisor = 1f/Factor; + const float Divisor = 1f / Factor; return new Vector2(Mathf.Round(x * Factor) * Divisor, Mathf.Round(y * Factor) * Divisor); } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs index c838b9ffe..1de7cda5a 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs @@ -35,26 +35,26 @@ #define NEW_PREFERENCES_SETTINGS_PROVIDER #endif -using UnityEngine; -using UnityEditor; using System.Threading; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { public class SpinePreferences : ScriptableObject { - #if NEW_PREFERENCES_SETTINGS_PROVIDER +#if NEW_PREFERENCES_SETTINGS_PROVIDER static int wasPreferencesDirCreated = 0; static int wasPreferencesAssetCreated = 0; - #endif +#endif public const string SPINE_SETTINGS_ASSET_PATH = "Assets/Editor/SpineSettings.asset"; - #if SPINE_TK2D +#if SPINE_TK2D internal const float DEFAULT_DEFAULT_SCALE = 1f; - #else +#else internal const float DEFAULT_DEFAULT_SCALE = 0.01f; - #endif +#endif public float defaultScale = DEFAULT_DEFAULT_SCALE; internal const float DEFAULT_DEFAULT_MIX = 0.2f; @@ -83,7 +83,7 @@ namespace Spine.Unity.Editor { return IsPMAWorkflow(textureSettingsReference); } } - public static bool IsPMAWorkflow(string textureSettingsReference) { + public static bool IsPMAWorkflow (string textureSettingsReference) { if (textureSettingsReference == null) return true; string settingsReference = textureSettingsReference.ToLower(); @@ -280,11 +280,11 @@ namespace Spine.Unity.Editor { } } - #if SPINE_TK2D_DEFINE +#if SPINE_TK2D_DEFINE bool isTK2DDefineSet = true; - #else +#else bool isTK2DDefineSet = false; - #endif +#endif bool isTK2DAllowed = SpineEditorUtilities.SpineTK2DEditorUtility.IsTK2DAllowed; if (SpineEditorUtilities.SpineTK2DEditorUtility.IsTK2DInstalled() || isTK2DDefineSet) { GUILayout.Space(20); @@ -296,12 +296,12 @@ namespace Spine.Unity.Editor { if (GUILayout.Button("Disable", GUILayout.Width(64))) SpineEditorUtilities.SpineTK2DEditorUtility.DisableTK2D(); } - #if !SPINE_TK2D_DEFINE +#if !SPINE_TK2D_DEFINE if (!isTK2DAllowed) { EditorGUILayout.LabelField("To allow TK2D support, please modify line 67 in", EditorStyles.boldLabel); EditorGUILayout.LabelField("Spine/Editor/spine-unity/Editor/Util./BuildSettings.cs", EditorStyles.boldLabel); } - #endif +#endif } GUILayout.Space(20); diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpriteAtlasImportWindow.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpriteAtlasImportWindow.cs index 3e6d86620..60894663a 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpriteAtlasImportWindow.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpriteAtlasImportWindow.cs @@ -29,8 +29,8 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; using UnityEditor; +using UnityEngine; namespace Spine.Unity.Editor { @@ -107,11 +107,9 @@ namespace Spine.Unity.Editor { using (new SpineInspectorUtility.BoxScope()) { if (spriteAtlasAsset == null) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Please assign SpriteAtlas file.", Icons.warning), GUILayout.Height(46)); - } - else if (spineSpriteAtlasAsset == null || spineSpriteAtlasAsset.RegionsNeedLoading) { + } else if (spineSpriteAtlasAsset == null || spineSpriteAtlasAsset.RegionsNeedLoading) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Please hit 'Load regions ..' to load\nregion info. Play mode is started\nand stopped automatically.", Icons.warning), GUILayout.Height(54)); - } - else { + } else { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("SpriteAtlas imported\nsuccessfully.", Icons.spine), GUILayout.Height(46)); } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonPartsRendererInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonPartsRendererInspector.cs index 79d4d9e45..07e3fbd94 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonPartsRendererInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonPartsRendererInspector.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using UnityEditor; using Spine.Unity.Editor; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Examples { [CustomEditor(typeof(SkeletonPartsRenderer))] diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs index 19712597c..74e4c4192 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs @@ -31,13 +31,11 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; -using UnityEditor; - -using System.Collections.Generic; - using Spine.Unity; using Spine.Unity.Editor; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; namespace Spine.Unity.Examples { @@ -66,9 +64,9 @@ namespace Spine.Unity.Examples { var partsRenderers = component.partsRenderers; partsRenderers_ = serializedObject.FindProperty("partsRenderers"); - partsRenderers_.isExpanded = partsRenderersExpanded || // last state - partsRenderers.Contains(null) || // null items found - partsRenderers.Count < 1 || // no parts renderers + partsRenderers_.isExpanded = partsRenderersExpanded || // last state + partsRenderers.Contains(null) || // null items found + partsRenderers.Count < 1 || // no parts renderers (skeletonRenderer_.objectReferenceValue != null && SkeletonRendererSeparatorCount + 1 > partsRenderers.Count); // not enough parts renderers } @@ -87,14 +85,14 @@ namespace Spine.Unity.Examples { // Triggers regeneration and assignment of the mesh filter's mesh. bool isMeshFilterAlwaysNull = false; - #if UNITY_EDITOR && NEW_PREFAB_SYSTEM +#if UNITY_EDITOR && NEW_PREFAB_SYSTEM // Don't store mesh or material at the prefab, otherwise it will permanently reload var prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(component); if (UnityEditor.PrefabUtility.IsPartOfPrefabAsset(component) && (prefabType == UnityEditor.PrefabAssetType.Regular || prefabType == UnityEditor.PrefabAssetType.Variant)) { isMeshFilterAlwaysNull = true; } - #endif +#endif if (!isMeshFilterAlwaysNull && component.GetComponent() && component.GetComponent().sharedMesh == null) { component.OnDisable(); @@ -171,7 +169,7 @@ namespace Spine.Unity.Examples { totalParts = separatorCount + 1; var counterStyle = skeletonRendererExpanded ? EditorStyles.label : EditorStyles.miniLabel; - EditorGUILayout.LabelField(string.Format("{0}: separates into {1}.", SpineInspectorUtility.Pluralize(separatorCount, "separator", "separators"), SpineInspectorUtility.Pluralize(totalParts, "part", "parts") ), counterStyle); + EditorGUILayout.LabelField(string.Format("{0}: separates into {1}.", SpineInspectorUtility.Pluralize(separatorCount, "separator", "separators"), SpineInspectorUtility.Pluralize(totalParts, "part", "parts")), counterStyle); } // Parts renderers @@ -301,7 +299,7 @@ namespace Spine.Unity.Examples { } #region SkeletonRenderer Context Menu Item - [MenuItem ("CONTEXT/SkeletonRenderer/Add Skeleton Render Separator")] + [MenuItem("CONTEXT/SkeletonRenderer/Add Skeleton Render Separator")] static void AddRenderSeparatorComponent (MenuCommand cmd) { var skeletonRenderer = cmd.context as SkeletonRenderer; var newComponent = skeletonRenderer.gameObject.AddComponent(); @@ -310,7 +308,7 @@ namespace Spine.Unity.Examples { } // Validate - [MenuItem ("CONTEXT/SkeletonRenderer/Add Skeleton Render Separator", true)] + [MenuItem("CONTEXT/SkeletonRenderer/Add Skeleton Render Separator", true)] static bool ValidateAddRenderSeparatorComponent (MenuCommand cmd) { var skeletonRenderer = cmd.context as SkeletonRenderer; var separator = skeletonRenderer.GetComponent(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AnimationReferenceAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AnimationReferenceAsset.cs index 494ce23e3..d5dd0d851 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AnimationReferenceAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AnimationReferenceAsset.cs @@ -44,10 +44,10 @@ namespace Spine.Unity { public Animation Animation { get { - #if AUTOINIT_SPINEREFERENCE +#if AUTOINIT_SPINEREFERENCE if (animation == null) Initialize(); - #endif +#endif return animation; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs index b361a3ba4..e4904a2a6 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs @@ -27,11 +27,11 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; using System; using System.Collections.Generic; using System.IO; using UnityEngine; -using Spine; namespace Spine.Unity { [System.Serializable] @@ -52,7 +52,7 @@ namespace Spine.Unity { public bool RequiresBlendModeMaterials { get { return requiresBlendModeMaterials; } set { requiresBlendModeMaterials = value; } } - public BlendMode BlendModeForMaterial(Material material) { + public BlendMode BlendModeForMaterial (Material material) { foreach (var pair in multiplyMaterials) if (pair.material == material) return BlendMode.Multiply; foreach (var pair in additiveMaterials) @@ -62,7 +62,7 @@ namespace Spine.Unity { return BlendMode.Normal; } - #if UNITY_EDITOR +#if UNITY_EDITOR public void TransferSettingsFrom (BlendModeMaterialsAsset modifierAsset) { applyAdditiveMaterial = modifierAsset.applyAdditiveMaterial; } @@ -92,7 +92,7 @@ namespace Spine.Unity { } return false; } - #endif +#endif public void ApplyMaterials (SkeletonData skeletonData) { if (skeletonData == null) throw new ArgumentNullException("skeletonData"); if (!requiresBlendModeMaterials) @@ -107,15 +107,15 @@ namespace Spine.Unity { List replacementMaterials = null; switch (slot.blendMode) { - case BlendMode.Multiply: - replacementMaterials = multiplyMaterials; - break; - case BlendMode.Screen: - replacementMaterials = screenMaterials; - break; - case BlendMode.Additive: - replacementMaterials = additiveMaterials; - break; + case BlendMode.Multiply: + replacementMaterials = multiplyMaterials; + break; + case BlendMode.Screen: + replacementMaterials = screenMaterials; + break; + case BlendMode.Additive: + replacementMaterials = additiveMaterials; + break; } if (replacementMaterials == null) continue; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/EventDataReferenceAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/EventDataReferenceAsset.cs index 38e41dfed..0d783f06c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/EventDataReferenceAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/EventDataReferenceAsset.cs @@ -42,10 +42,10 @@ namespace Spine.Unity { EventData eventData; public EventData EventData { get { - #if AUTOINIT_SPINEREFERENCE +#if AUTOINIT_SPINEREFERENCE if (eventData == null) Initialize(); - #endif +#endif return eventData; } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs index 746d2a4a3..f749f8e87 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs @@ -41,12 +41,12 @@ namespace Spine.Unity { #region Inspector public AtlasAssetBase[] atlasAssets = new AtlasAssetBase[0]; - #if SPINE_TK2D +#if SPINE_TK2D public tk2dSpriteCollectionData spriteCollection; public float scale = 1f; - #else +#else public float scale = 0.01f; - #endif +#endif public TextAsset skeletonJSON; public bool isUpgradingBlendModeMaterials = false; @@ -77,7 +77,7 @@ namespace Spine.Unity { /// /// Creates a runtime SkeletonDataAsset. public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAssetBase atlasAsset, bool initialize, float scale = 0.01f) { - return CreateRuntimeInstance(skeletonDataFile, new [] {atlasAsset}, initialize, scale); + return CreateRuntimeInstance(skeletonDataFile, new[] { atlasAsset }, initialize, scale); } /// @@ -145,10 +145,10 @@ namespace Spine.Unity { float skeletonDataScale; Atlas[] atlasArray = this.GetAtlasArray(); - #if !SPINE_TK2D +#if !SPINE_TK2D attachmentLoader = (atlasArray.Length == 0) ? (AttachmentLoader)new RegionlessAttachmentLoader() : (AttachmentLoader)new AtlasAttachmentLoader(atlasArray); skeletonDataScale = scale; - #else +#else if (spriteCollection != null) { attachmentLoader = new Spine.Unity.TK2D.SpriteCollectionAttachmentLoader(spriteCollection); skeletonDataScale = (1.0f / (spriteCollection.invOrthoSize * spriteCollection.halfTargetHeight) * scale); @@ -161,7 +161,7 @@ namespace Spine.Unity { attachmentLoader = new AtlasAttachmentLoader(atlasArray); skeletonDataScale = scale; } - #endif +#endif bool hasBinaryExtension = skeletonJSON.name.ToLower().Contains(".skel"); SkeletonData loadedSkeletonData = null; @@ -176,7 +176,7 @@ namespace Spine.Unity { Debug.LogError("Error reading skeleton JSON file for SkeletonData asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, skeletonJSON); } - #if UNITY_EDITOR +#if UNITY_EDITOR if (loadedSkeletonData == null && !quiet && skeletonJSON != null) { string problemDescription = null; bool isSpineSkeletonData; @@ -192,7 +192,7 @@ namespace Spine.Unity { return null; } } - #endif +#endif if (loadedSkeletonData == null) return null; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs index 67dd5ac01..02910f609 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using System; using System.Collections.Generic; using System.IO; using UnityEngine; -using System; #if UNITY_EDITOR using System.Globalization; using System.Text.RegularExpressions; @@ -40,13 +40,13 @@ namespace Spine.Unity { public static class SkeletonDataCompatibility { - #if UNITY_EDITOR +#if UNITY_EDITOR static readonly int[][] compatibleBinaryVersions = { new[] { 4, 0, 0 } }; static readonly int[][] compatibleJsonVersions = { new[] { 4, 0, 0 } }; static bool wasVersionDialogShown = false; static readonly Regex jsonVersionRegex = new Regex(@"""spine""\s*:\s*""([^""]+)""", RegexOptions.CultureInvariant); - #endif +#endif public enum SourceType { Json, @@ -81,7 +81,7 @@ namespace Spine.Unity { } } - #if UNITY_EDITOR +#if UNITY_EDITOR public static VersionInfo GetVersionInfo (TextAsset asset, out bool isSpineSkeletonData, ref string problemDescription) { isSpineSkeletonData = false; if (asset == null) @@ -210,6 +210,6 @@ namespace Spine.Unity { Debug.LogError(string.Format("Error importing skeleton '{0}': {1}", spineJson.name, descriptionString), spineJson); } - #endif // UNITY_EDITOR +#endif // UNITY_EDITOR } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs index 9f4c03e58..de458b665 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs @@ -27,11 +27,11 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; using System; using System.Collections.Generic; using System.IO; using UnityEngine; -using Spine; namespace Spine.Unity { /// Loads and stores a Spine atlas and list of materials. @@ -214,8 +214,8 @@ namespace Spine.Unity { } public class NoOpTextureLoader : TextureLoader { - public void Load (AtlasPage page, string path) {} - public void Unload (object texture) {} + public void Load (AtlasPage page, string path) { } + public void Unload (object texture) { } } public class MaterialsTextureLoader : TextureLoader { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineSpriteAtlasAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineSpriteAtlasAsset.cs index f84e19693..9006ff2a1 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineSpriteAtlasAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineSpriteAtlasAsset.cs @@ -31,11 +31,11 @@ #define EXPOSES_SPRITE_ATLAS_UTILITIES #endif +using Spine; using System; using System.Collections.Generic; using System.IO; using UnityEngine; -using Spine; using UnityEngine.U2D; #if UNITY_EDITOR @@ -65,12 +65,12 @@ namespace Spine.Unity { public override int MaterialCount { get { return materials == null ? 0 : materials.Length; } } public override Material PrimaryMaterial { get { return materials[0]; } } - #if UNITY_EDITOR +#if UNITY_EDITOR static MethodInfo GetPackedSpritesMethod, GetPreviewTexturesMethod; - #if !EXPOSES_SPRITE_ATLAS_UTILITIES +#if !EXPOSES_SPRITE_ATLAS_UTILITIES static MethodInfo PackAtlasesMethod; - #endif - #endif +#endif +#endif #region Runtime Instantiation /// @@ -180,17 +180,17 @@ namespace Spine.Unity { return new Atlas(pages, regions); Texture2D texture = null; - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) texture = AccessPackedTextureEditor(spriteAtlas); else - #endif - texture = AccessPackedTexture(sprites); +#endif + texture = AccessPackedTexture(sprites); Material material = materials[0]; - #if !UNITY_EDITOR +#if !UNITY_EDITOR material.mainTexture = texture; - #endif +#endif Spine.AtlasPage page = new AtlasPage(); page.name = spriteAtlas.name; @@ -208,7 +208,7 @@ namespace Spine.Unity { sprites = AccessPackedSprites(spriteAtlas); int i = 0; - for ( ; i < sprites.Length; ++i) { + for (; i < sprites.Length; ++i) { var sprite = sprites[i]; AtlasRegion region = new AtlasRegion(); region.name = sprite.name.Replace("(Clone)", ""); @@ -335,9 +335,9 @@ namespace Spine.Unity { } public static Texture2D AccessPackedTextureEditor (SpriteAtlas spriteAtlas) { - #if EXPOSES_SPRITE_ATLAS_UTILITIES +#if EXPOSES_SPRITE_ATLAS_UTILITIES UnityEditor.U2D.SpriteAtlasUtility.PackAtlases(new SpriteAtlas[] { spriteAtlas }, EditorUserBuildSettings.activeBuildTarget); - #else +#else /*if (PackAtlasesMethod == null) { System.Type T = Type.GetType("UnityEditor.U2D.SpriteAtlasUtility,UnityEditor"); PackAtlasesMethod = T.GetMethod("PackAtlases", BindingFlags.NonPublic | BindingFlags.Static); @@ -345,7 +345,7 @@ namespace Spine.Unity { if (PackAtlasesMethod != null) { PackAtlasesMethod.Invoke(null, new object[] { new SpriteAtlas[] { spriteAtlas }, EditorUserBuildSettings.activeBuildTarget }); }*/ - #endif +#endif if (GetPreviewTexturesMethod == null) { System.Type T = Type.GetType("UnityEditor.U2D.SpriteAtlasExtensions,UnityEditor"); GetPreviewTexturesMethod = T.GetMethod("GetPreviewTextures", BindingFlags.NonPublic | BindingFlags.Static); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs index d6c59de8c..afce43783 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollower.cs @@ -37,11 +37,11 @@ using UnityEngine; namespace Spine.Unity { /// Sets a GameObject's transform to match a bone on a Spine skeleton. - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [AddComponentMenu("Spine/BoneFollower")] [HelpURL("http://esotericsoftware.com/spine-unity#BoneFollower")] public class BoneFollower : MonoBehaviour { @@ -124,10 +124,10 @@ namespace Spine.Unity { if (!string.IsNullOrEmpty(boneName)) bone = skeletonRenderer.skeleton.FindBone(boneName); - #if UNITY_EDITOR +#if UNITY_EDITOR if (Application.isEditor) LateUpdate(); - #endif +#endif } void OnDestroy () { @@ -141,10 +141,10 @@ namespace Spine.Unity { return; } - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) skeletonTransformIsParent = Transform.ReferenceEquals(skeletonTransform, transform.parent); - #endif +#endif if (bone == null) { if (string.IsNullOrEmpty(boneName)) return; @@ -190,8 +190,7 @@ namespace Spine.Unity { if (followSkeletonFlip || maintainedAxisOrientation == AxisOrientation.XAxis) { if ((skeletonLossyScale.x * parentLossyScale.x < 0)) boneWorldRotation += 180f; - } - else { + } else { if ((skeletonLossyScale.y * parentLossyScale.y < 0)) boneWorldRotation += 180f; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs index 6d5ea7bef..4c611b4b8 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs @@ -37,11 +37,11 @@ using UnityEngine; namespace Spine.Unity { using AxisOrientation = BoneFollower.AxisOrientation; - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [RequireComponent(typeof(RectTransform)), DisallowMultipleComponent] [AddComponentMenu("Spine/UI/BoneFollowerGraphic")] [HelpURL("http://esotericsoftware.com/spine-unity#BoneFollowerGraphic")] @@ -103,18 +103,18 @@ namespace Spine.Unity { if (!valid) return; skeletonTransform = skeletonGraphic.transform; -// skeletonGraphic.OnRebuild -= HandleRebuildRenderer; -// skeletonGraphic.OnRebuild += HandleRebuildRenderer; + // skeletonGraphic.OnRebuild -= HandleRebuildRenderer; + // skeletonGraphic.OnRebuild += HandleRebuildRenderer; skeletonTransformIsParent = Transform.ReferenceEquals(skeletonTransform, transform.parent); if (!string.IsNullOrEmpty(boneName)) bone = skeletonGraphic.Skeleton.FindBone(boneName); - #if UNITY_EDITOR +#if UNITY_EDITOR if (Application.isEditor) { LateUpdate(); } - #endif +#endif } public void LateUpdate () { @@ -123,10 +123,10 @@ namespace Spine.Unity { return; } - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) skeletonTransformIsParent = Transform.ReferenceEquals(skeletonTransform, transform.parent); - #endif +#endif if (bone == null) { if (string.IsNullOrEmpty(boneName)) return; @@ -169,8 +169,7 @@ namespace Spine.Unity { if (followSkeletonFlip || maintainedAxisOrientation == AxisOrientation.XAxis) { if ((skeletonLossyScale.x * parentLossyScale.x < 0)) boneWorldRotation += 180f; - } - else { + } else { if ((skeletonLossyScale.y * parentLossyScale.y < 0)) boneWorldRotation += 180f; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs index f841a02ef..df6128f78 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs @@ -31,16 +31,16 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [HelpURL("http://esotericsoftware.com/spine-unity#BoundingBoxFollower")] public class BoundingBoxFollower : MonoBehaviour { internal static bool DebugMessages = true; @@ -99,11 +99,11 @@ namespace Spine.Unity { // Don't reinitialize if the setup did not change. if (!overwrite && - colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated. + colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated. && - skeletonRenderer.skeleton == slot.Skeleton // Skeleton object did not change. + skeletonRenderer.skeleton == slot.Skeleton // Skeleton object did not change. && - slotName == slot.data.name // Slot object did not change. + slotName == slot.data.name // Slot object did not change. ) return; @@ -207,7 +207,7 @@ namespace Spine.Unity { DestroyImmediate(collider); else #endif - Destroy(collider); + Destroy(collider); } } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs index 674a0fb04..2dfbdf640 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs @@ -31,16 +31,16 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [HelpURL("http://esotericsoftware.com/spine-unity#BoundingBoxFollowerGraphic")] public class BoundingBoxFollowerGraphic : MonoBehaviour { internal static bool DebugMessages = true; @@ -99,11 +99,11 @@ namespace Spine.Unity { // Don't reinitialize if the setup did not change. if (!overwrite && - colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated. + colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated. && - skeletonGraphic.Skeleton == slot.Skeleton // Skeleton object did not change. + skeletonGraphic.Skeleton == slot.Skeleton // Skeleton object did not change. && - slotName == slot.data.name // Slot object did not change. + slotName == slot.data.name // Slot object did not change. ) return; @@ -211,7 +211,7 @@ namespace Spine.Unity { DestroyImmediate(collider); else #endif - Destroy(collider); + Destroy(collider); } } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs index 25aa203ff..62a20e3bf 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/PointFollower.cs @@ -35,11 +35,11 @@ using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [AddComponentMenu("Spine/Point Follower")] [HelpURL("http://esotericsoftware.com/spine-unity#PointFollower")] public class PointFollower : MonoBehaviour, IHasSkeletonRenderer, IHasSkeletonComponent { @@ -48,10 +48,10 @@ namespace Spine.Unity { public SkeletonRenderer SkeletonRenderer { get { return this.skeletonRenderer; } } public ISkeletonComponent SkeletonComponent { get { return skeletonRenderer as ISkeletonComponent; } } - [SpineSlot(dataField:"skeletonRenderer", includeNone: true)] + [SpineSlot(dataField: "skeletonRenderer", includeNone: true)] public string slotName; - [SpineAttachment(slotField:"slotName", dataField: "skeletonRenderer", fallbackToTextField:true, includeNone: true)] + [SpineAttachment(slotField: "slotName", dataField: "skeletonRenderer", fallbackToTextField: true, includeNone: true)] public string pointAttachmentName; public bool followRotation = true; @@ -72,9 +72,9 @@ namespace Spine.Unity { UpdateReferences(); - #if UNITY_EDITOR +#if UNITY_EDITOR if (Application.isEditor) LateUpdate(); - #endif +#endif } private void HandleRebuildRenderer (SkeletonRenderer skeletonRenderer) { @@ -107,9 +107,9 @@ namespace Spine.Unity { } public void LateUpdate () { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) skeletonTransformIsParent = Transform.ReferenceEquals(skeletonTransform, transform.parent); - #endif +#endif if (point == null) { if (string.IsNullOrEmpty(pointAttachmentName)) return; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs index 0ddae609c..bf2818b72 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs @@ -38,8 +38,8 @@ namespace Spine.Unity { /// [RequireComponent(typeof(CanvasRenderer))] public class SkeletonSubmeshGraphic : MaskableGraphic { - public override void SetMaterialDirty () {} - public override void SetVerticesDirty () {} + public override void SetMaterialDirty () { } + public override void SetVerticesDirty () { } protected override void OnPopulateMesh (VertexHelper vh) { vh.Clear(); } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonMecanimRootMotion.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonMecanimRootMotion.cs index 4a90bdb00..174eea129 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonMecanimRootMotion.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonMecanimRootMotion.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections.Generic; using Spine.Unity.AnimationTools; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { @@ -96,16 +96,15 @@ namespace Spine.Unity { } } - void OnClipApplied(Spine.Animation animation, int layerIndex, float weight, + void OnClipApplied (Spine.Animation animation, int layerIndex, float weight, float time, float lastTime, bool playsBackward) { - if (((mecanimLayerFlags & 1< 1) mix = 1; } float mixAndAlpha = track.alpha * next.interruptAlpha * (1 - mix); currentDelta *= mixAndAlpha; - } - else { + } else { if (track.mixDuration == 0) { mix = 1; - } - else { + } else { mix = track.alpha * (track.mixTime / track.mixDuration); if (mix > 1) mix = 1; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs index 05833d037..ecf8925fd 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections.Generic; using Spine.Unity.AnimationTools; using System; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs index 48c4ec713..4713a2364 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs @@ -35,11 +35,11 @@ using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [AddComponentMenu("Spine/SkeletonAnimation")] [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonAnimation-Component")] public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation, IAnimationStateComponent { @@ -177,21 +177,21 @@ namespace Spine.Unity { var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(_animationName); if (animationObject != null) { state.SetAnimation(0, animationObject, loop); - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) Update(0f); - #endif +#endif } } } void Update () { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) { Update(0f); return; } - #endif +#endif Update(Time.deltaTime); } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index 4c9c3eaf2..a6d52b44e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -41,11 +41,11 @@ using UnityEngine; using UnityEngine.UI; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [RequireComponent(typeof(CanvasRenderer), typeof(RectTransform)), DisallowMultipleComponent] [AddComponentMenu("Spine/SkeletonGraphic (Unity UI Canvas)")] [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonGraphic-Component")] @@ -59,11 +59,11 @@ namespace Spine.Unity { public Material multiplyMaterial; public Material screenMaterial; - [SpineSkin(dataField:"skeletonDataAsset", defaultAsEmptyString:true)] + [SpineSkin(dataField: "skeletonDataAsset", defaultAsEmptyString: true)] public string initialSkinName; public bool initialFlipX, initialFlipY; - [SpineAnimation(dataField:"skeletonDataAsset")] + [SpineAnimation(dataField: "skeletonDataAsset")] public string startingAnimation; public bool startingLoop; public float timeScale = 1f; @@ -99,7 +99,7 @@ namespace Spine.Unity { private bool wasUpdatedAfterInit = true; private Texture baseTexture = null; - #if UNITY_EDITOR +#if UNITY_EDITOR protected override void OnValidate () { // This handles Scene View preview. base.OnValidate (); @@ -155,7 +155,7 @@ namespace Spine.Unity { if (material == null || material.shader != Shader.Find("Spine/SkeletonGraphic")) Debug.LogWarning("SkeletonGraphic works best with the SkeletonGraphic material."); } - #endif +#endif #endregion #region Runtime Instantiation @@ -210,7 +210,7 @@ namespace Spine.Unity { protected override void Awake () { - base.Awake (); + base.Awake(); this.onCullStateChanged.AddListener(OnCullStateChanged); SyncSubmeshGraphicsWithCanvasRenderers(); @@ -236,7 +236,7 @@ namespace Spine.Unity { public override void Rebuild (CanvasUpdate update) { base.Rebuild(update); if (canvasRenderer.cull) return; - if (update == CanvasUpdate.PreRender) UpdateMesh(keepRendererCount : true); + if (update == CanvasUpdate.PreRender) UpdateMesh(keepRendererCount: true); if (allowMultipleCanvasRenderers) canvasRenderer.Clear(); } @@ -248,12 +248,12 @@ namespace Spine.Unity { } public virtual void Update () { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) { Update(0f); return; } - #endif +#endif if (freeze) return; Update(unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime); @@ -301,7 +301,7 @@ namespace Spine.Unity { BeforeApply(this); if (updateMode != UpdateMode.OnlyEventTimelines) - state.Apply(skeleton); + state.Apply(skeleton); else state.ApplyEventTimelinesOnly(skeleton); @@ -356,12 +356,12 @@ namespace Spine.Unity { if (slot != null) { separatorSlots.Add(slot); } - #if UNITY_EDITOR +#if UNITY_EDITOR else { Debug.LogWarning(slotName + " is not a slot in " + skeletonDataAsset.skeletonJSON.name); } - #endif +#endif } UpdateSeparatorPartParents(); } @@ -499,8 +499,7 @@ namespace Spine.Unity { foreach (var canvasRenderer in canvasRenderers) { if (canvasRenderer.gameObject.activeSelf) { newList.Add(canvasRenderer); - } - else { + } else { if (Application.isEditor && !Application.isPlaying) DestroyImmediate(canvasRenderer.gameObject); else @@ -548,10 +547,10 @@ namespace Spine.Unity { var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(startingAnimation); if (animationObject != null) { state.SetAnimation(0, animationObject, startingLoop); - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) Update(0f); - #endif +#endif } } @@ -567,8 +566,7 @@ namespace Spine.Unity { var currentInstructions = this.currentInstructions; if (!this.allowMultipleCanvasRenderers) { UpdateMeshSingleCanvasRenderer(); - } - else { + } else { UpdateMeshMultipleCanvasRenderers(currentInstructions, keepRendererCount); } @@ -587,8 +585,7 @@ namespace Spine.Unity { if (meshBuffers != null) { meshBuffers.GetNext().Clear(); meshBuffers.GetNext().Clear(); - } - else { + } else { meshBuffers = new DoubleBuffered(); } } @@ -603,7 +600,7 @@ namespace Spine.Unity { protected void UpdateMeshSingleCanvasRenderer () { if (canvasRenderers.Count > 0) - DisableUnusedCanvasRenderers(usedCount : 0); + DisableUnusedCanvasRenderers(usedCount: 0); var smartMesh = meshBuffers.GetNext(); MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, null); @@ -612,8 +609,7 @@ namespace Spine.Unity { meshGenerator.Begin(); if (currentInstructions.hasActiveClipping && currentInstructions.submeshInstructions.Count > 0) { meshGenerator.AddSubmesh(currentInstructions.submeshInstructions.Items[0], updateTriangles); - } - else { + } else { meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles); } @@ -672,9 +668,9 @@ namespace Spine.Unity { BlendModeMaterials blendModeMaterials = skeletonDataAsset.blendModeMaterials; bool hasBlendModeMaterials = blendModeMaterials.RequiresBlendModeMaterials; - #if HAS_CULL_TRANSPARENT_MESH +#if HAS_CULL_TRANSPARENT_MESH bool mainCullTransparentMesh = this.canvasRenderer.cullTransparentMesh; - #endif +#endif bool pmaVertexColors = meshGenerator.settings.pmaVertexColors; int targetSiblingIndex = 0; for (int i = 0; i < submeshCount; i++) { @@ -729,10 +725,10 @@ namespace Spine.Unity { usedMaterial = screenMaterial; canvasRenderer.SetMaterial(usedMaterial, usedTexture); - #if HAS_CULL_TRANSPARENT_MESH +#if HAS_CULL_TRANSPARENT_MESH canvasRenderer.cullTransparentMesh = allowCullTransparentMesh ? mainCullTransparentMesh : false; - #endif +#endif } } else { var originalTexture = submeshMaterial.mainTexture; @@ -746,14 +742,14 @@ namespace Spine.Unity { } } - DisableUnusedCanvasRenderers(usedCount : submeshCount); + DisableUnusedCanvasRenderers(usedCount: submeshCount); usedRenderersCount = submeshCount; } protected void EnsureCanvasRendererCount (int targetCount) { - #if UNITY_EDITOR +#if UNITY_EDITOR RemoveNullCanvasRenderers(); - #endif +#endif int currentCount = canvasRenderers.Count; for (int i = currentCount; i < targetCount; ++i) { var go = new GameObject(string.Format("Renderer{0}", i), typeof(RectTransform)); @@ -769,16 +765,16 @@ namespace Spine.Unity { } protected void DisableUnusedCanvasRenderers (int usedCount) { - #if UNITY_EDITOR +#if UNITY_EDITOR RemoveNullCanvasRenderers(); - #endif +#endif for (int i = usedCount; i < canvasRenderers.Count; i++) { canvasRenderers[i].Clear(); canvasRenderers[i].gameObject.SetActive(false); } } - #if UNITY_EDITOR +#if UNITY_EDITOR private void RemoveNullCanvasRenderers () { if (Application.isEditor && !Application.isPlaying) { for (int i = canvasRenderers.Count - 1; i >= 0; --i) { @@ -814,21 +810,21 @@ namespace Spine.Unity { else UnityEngine.Object.Destroy(mesh); #else - UnityEngine.Object.Destroy(mesh); + UnityEngine.Object.Destroy(mesh); #endif } meshes.Clear(); } protected void EnsureSeparatorPartCount () { - #if UNITY_EDITOR +#if UNITY_EDITOR RemoveNullSeparatorParts(); - #endif +#endif int targetCount = separatorSlots.Count + 1; if (targetCount == 1) return; - #if UNITY_EDITOR +#if UNITY_EDITOR if (Application.isEditor && !Application.isPlaying) { for (int i = separatorParts.Count-1; i >= 0; --i) { if (separatorParts[i] == null) { @@ -836,7 +832,7 @@ namespace Spine.Unity { } } } - #endif +#endif int currentCount = separatorParts.Count; for (int i = currentCount; i < targetCount; ++i) { var go = new GameObject(string.Format("{0}[{1}]", SeparatorPartGameObjectName, i), typeof(RectTransform)); @@ -864,7 +860,7 @@ namespace Spine.Unity { } } - #if UNITY_EDITOR +#if UNITY_EDITOR private void RemoveNullSeparatorParts () { if (Application.isEditor && !Application.isPlaying) { for (int i = separatorParts.Count - 1; i >= 0; --i) { @@ -874,6 +870,6 @@ namespace Spine.Unity { } } } - #endif +#endif } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs index 46dcfe76f..f0432be94 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { [RequireComponent(typeof(Animator))] @@ -97,7 +97,7 @@ namespace Spine.Unity { if (_BeforeApply != null) _BeforeApply(this); - #if UNITY_EDITOR +#if UNITY_EDITOR var translatorAnimator = translator.Animator; if (translatorAnimator != null && !translatorAnimator.isInitialized) translatorAnimator.Rebind(); @@ -113,9 +113,9 @@ namespace Spine.Unity { translator.Apply(skeleton); } } - #else +#else translator.Apply(skeleton); - #endif +#endif // UpdateWorldTransform and Bone Callbacks { @@ -206,7 +206,7 @@ namespace Spine.Unity { } } - public void Initialize(Animator animator, SkeletonDataAsset skeletonDataAsset) { + public void Initialize (Animator animator, SkeletonDataAsset skeletonDataAsset) { this.animator = animator; previousAnimations.Clear(); @@ -278,11 +278,11 @@ namespace Spine.Unity { } public void Apply (Skeleton skeleton) { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) { GetLayerBlendModes(); } - #endif +#endif if (layerMixModes.Length < animator.layerCount) { int oldSize = layerMixModes.Length; @@ -340,8 +340,7 @@ namespace Spine.Unity { } if (isInterruptionActive) { - for (int c = 0; c < interruptingClipInfoCount; c++) - { + for (int c = 0; c < interruptingClipInfoCount; c++) { var info = interruptingClipInfo[c]; float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight; float weight = clipWeight * layerWeight; if (weight < WeightEpsilon) continue; @@ -385,18 +384,17 @@ namespace Spine.Unity { } } if (isInterruptionActive) { - for (int c = 0; c < interruptingClipInfoCount; c++) - { + for (int c = 0; c < interruptingClipInfoCount; c++) { ApplyInterruptionAnimation(skeleton, interpolateWeightTo1, interruptingClipInfo[c], interruptingStateInfo, layer, layerWeight, layerBlendMode, interruptingClipTimeAddition); } } } else { // case MixNext || Hard - // Apply first non-zero weighted clip + // Apply first non-zero weighted clip int c = 0; for (; c < clipInfoCount; c++) { - if (!ApplyAnimation(skeleton, clipInfo[c], stateInfo, layer, layerWeight, layerBlendMode, useClipWeight1:true)) + if (!ApplyAnimation(skeleton, clipInfo[c], stateInfo, layer, layerWeight, layerBlendMode, useClipWeight1: true)) continue; ++c; break; } @@ -410,7 +408,7 @@ namespace Spine.Unity { // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights) if (mode == MixMode.Hard) { for (; c < nextClipInfoCount; c++) { - if (!ApplyAnimation(skeleton, nextClipInfo[c], nextStateInfo, layer, layerWeight, layerBlendMode, useClipWeight1:true)) + if (!ApplyAnimation(skeleton, nextClipInfo[c], nextStateInfo, layer, layerWeight, layerBlendMode, useClipWeight1: true)) continue; ++c; break; } @@ -429,7 +427,7 @@ namespace Spine.Unity { for (; c < interruptingClipInfoCount; c++) { if (ApplyInterruptionAnimation(skeleton, interpolateWeightTo1, interruptingClipInfo[c], interruptingStateInfo, - layer, layerWeight, layerBlendMode, interruptingClipTimeAddition, useClipWeight1:true)) { + layer, layerWeight, layerBlendMode, interruptingClipTimeAddition, useClipWeight1: true)) { ++c; break; } @@ -458,8 +456,7 @@ namespace Spine.Unity { if (isInterruptionActive && layerInfos.interruptingClipInfoCount > 0) { clip = layerInfos.interruptingClipInfos[0].clip; stateInfo = layerInfos.interruptingStateInfo; - } - else { + } else { clip = layerInfos.clipInfos[0].clip; stateInfo = layerInfos.stateInfo; } @@ -519,8 +516,7 @@ namespace Spine.Unity { layerMixModes[layer] = mode; } return mode; - } - else { + } else { return layerBlendMode == MixBlend.Add ? MixMode.AlwaysMix : MixMode.MixNext; } } @@ -541,7 +537,7 @@ namespace Spine.Unity { } } } - #endif +#endif void GetStateUpdatesFromAnimator (int layer) { @@ -653,7 +649,7 @@ namespace Spine.Unity { class IntEqualityComparer : IEqualityComparer { internal static readonly IEqualityComparer Instance = new IntEqualityComparer(); public bool Equals (int x, int y) { return x == y; } - public int GetHashCode(int o) { return o; } + public int GetHashCode (int o) { return o; } } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs index d2d187ef2..9aa8f126f 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs @@ -32,16 +32,16 @@ #endif #define SPINE_OPTIONAL_RENDEROVERRIDE -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonRenderSeparator")] public class SkeletonRenderSeparator : MonoBehaviour { public const int DefaultSortingOrderIncrement = 5; @@ -52,10 +52,10 @@ namespace Spine.Unity { public SkeletonRenderer SkeletonRenderer { get { return skeletonRenderer; } set { - #if SPINE_OPTIONAL_RENDEROVERRIDE +#if SPINE_OPTIONAL_RENDEROVERRIDE if (skeletonRenderer != null) skeletonRenderer.GenerateMeshOverride -= HandleRender; - #endif +#endif skeletonRenderer = value; if (value == null) @@ -69,12 +69,12 @@ namespace Spine.Unity { public bool copyMeshRendererFlags = true; public List partsRenderers = new List(); - #if UNITY_EDITOR +#if UNITY_EDITOR void Reset () { if (skeletonRenderer == null) skeletonRenderer = GetComponent(); } - #endif +#endif #endregion #region Callback Delegates @@ -119,14 +119,14 @@ namespace Spine.Unity { srs.OnEnable(); - #if UNITY_EDITOR +#if UNITY_EDITOR // Make sure editor updates properly in edit mode. if (!Application.isPlaying) { skeletonRenderer.enabled = false; skeletonRenderer.enabled = true; skeletonRenderer.LateUpdate(); } - #endif +#endif return srs; } @@ -161,10 +161,10 @@ namespace Spine.Unity { if (copiedBlock == null) copiedBlock = new MaterialPropertyBlock(); mainMeshRenderer = skeletonRenderer.GetComponent(); - #if SPINE_OPTIONAL_RENDEROVERRIDE +#if SPINE_OPTIONAL_RENDEROVERRIDE skeletonRenderer.GenerateMeshOverride -= HandleRender; skeletonRenderer.GenerateMeshOverride += HandleRender; - #endif +#endif if (copyMeshRendererFlags) { var lightProbeUsage = mainMeshRenderer.lightProbeUsage; @@ -191,9 +191,9 @@ namespace Spine.Unity { public void OnDisable () { if (skeletonRenderer == null) return; - #if SPINE_OPTIONAL_RENDEROVERRIDE +#if SPINE_OPTIONAL_RENDEROVERRIDE skeletonRenderer.GenerateMeshOverride -= HandleRender; - #endif +#endif skeletonRenderer.LateUpdate(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index c42368a47..130c06791 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -51,11 +51,11 @@ using UnityEngine; namespace Spine.Unity { /// Base class of animated Spine skeleton components. This component manages and renders a skeleton. - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [RequireComponent(typeof(MeshRenderer)), DisallowMultipleComponent] [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonRenderer-Component")] public class SkeletonRenderer : MonoBehaviour, ISkeletonComponent, IHasSkeletonDataAsset { @@ -63,11 +63,11 @@ namespace Spine.Unity { #region Initialization settings /// Skin name to use when the Skeleton is initialized. - [SpineSkin(defaultAsEmptyString:true)] public string initialSkinName; + [SpineSkin(defaultAsEmptyString: true)] public string initialSkinName; /// Enable this parameter when overwriting the Skeleton's skin from an editor script. /// Otherwise any changes will be overwritten by the next inspector update. - #if UNITY_EDITOR +#if UNITY_EDITOR public bool EditorSkipSkinSync { get { return editorSkipSkinSync; } set { editorSkipSkinSync = value; } @@ -84,7 +84,7 @@ namespace Spine.Unity { meshFilter = gameObject.AddComponent(); } if (fixPrefabOverrideViaMeshFilter) { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM if (UnityEditor.PrefabUtility.IsPartOfAnyPrefab(meshFilter)) { var instanceRoot = UnityEditor.PrefabUtility.GetOutermostPrefabInstanceRoot(meshFilter); if (instanceRoot != null) { @@ -97,14 +97,14 @@ namespace Spine.Unity { } } } - #endif +#endif meshFilter.hideFlags = HideFlags.DontSaveInEditor; } else { meshFilter.hideFlags = HideFlags.None; } } - #endif +#endif /// Flip X and Y to use when the Skeleton is initialized. public bool initialFlipX, initialFlipY; #endregion @@ -122,7 +122,7 @@ namespace Spine.Unity { // Submesh Separation /// Slot names used to populate separatorSlots list when the Skeleton is initialized. Changing this after initialization does nothing. - [UnityEngine.Serialization.FormerlySerializedAs("submeshSeparators")][SerializeField][SpineSlot] protected string[] separatorSlotNames = new string[0]; + [UnityEngine.Serialization.FormerlySerializedAs("submeshSeparators")] [SerializeField] [SpineSlot] protected string[] separatorSlotNames = new string[0]; /// Slots that determine where the render is split. This is used by components such as SkeletonRenderSeparator so that the skeleton can be rendered by two separate renderers on different GameObjects. [System.NonSerialized] public readonly List separatorSlots = new List(); @@ -148,7 +148,7 @@ namespace Spine.Unity { /// This disables SkeletonRenderSeparator functionality. public bool singleSubmesh = false; - #if PER_MATERIAL_PROPERTY_BLOCKS +#if PER_MATERIAL_PROPERTY_BLOCKS /// Applies only when 3+ submeshes are used (2+ materials with alternating order, e.g. "A B A"). /// If true, GPU instancing is disabled at all materials and MaterialPropertyBlocks are assigned at each /// material to prevent aggressive batching of submeshes by e.g. the LWRP renderer, leading to incorrect @@ -156,7 +156,7 @@ namespace Spine.Unity { /// You can disable this parameter when everything is drawn correctly to save the additional performance cost. /// public bool fixDrawOrder = false; - #endif +#endif /// If true, the mesh generator adds normals to the output mesh. For better performance and reduced memory requirements, use a shader that assumes the desired normal. [UnityEngine.Serialization.FormerlySerializedAs("calculateNormals")] public bool addNormals = false; @@ -164,7 +164,7 @@ namespace Spine.Unity { /// If true, tangents are calculated every frame and added to the Mesh. Enable this when using a shader that uses lighting that requires tangents. public bool calculateTangents = false; - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT /// This enum controls the mode under which the sprite will interact with the masking system. /// Interaction modes with components are identical to Unity's , /// see https://docs.unity3d.com/ScriptReference/SpriteMaskInteraction.html. @@ -198,14 +198,14 @@ namespace Spine.Unity { public const UnityEngine.Rendering.CompareFunction STENCIL_COMP_MASKINTERACTION_VISIBLE_INSIDE = UnityEngine.Rendering.CompareFunction.LessEqual; /// Shader property value used as Stencil comparison function for . public const UnityEngine.Rendering.CompareFunction STENCIL_COMP_MASKINTERACTION_VISIBLE_OUTSIDE = UnityEngine.Rendering.CompareFunction.Greater; - #if UNITY_EDITOR +#if UNITY_EDITOR private static bool haveStencilParametersBeenFixed = false; - #endif - #endif // #if BUILT_IN_SPRITE_MASK_COMPONENT +#endif +#endif // #if BUILT_IN_SPRITE_MASK_COMPONENT #endregion #region Overrides - #if SPINE_OPTIONAL_RENDEROVERRIDE +#if SPINE_OPTIONAL_RENDEROVERRIDE // These are API for anything that wants to take over rendering for a SkeletonRenderer. public bool disableRenderingOnOverride = true; public delegate void InstructionDelegate (SkeletonRendererInstruction instruction); @@ -233,13 +233,13 @@ namespace Spine.Unity { /// Occurs after the vertex data is populated every frame, before the vertices are pushed into the mesh. public event Spine.Unity.MeshGeneratorDelegate OnPostProcessVertices; - #endif +#endif - #if SPINE_OPTIONAL_MATERIALOVERRIDE +#if SPINE_OPTIONAL_MATERIALOVERRIDE [System.NonSerialized] readonly Dictionary customMaterialOverride = new Dictionary(); /// Use this Dictionary to override a Material with a different Material. public Dictionary CustomMaterialOverride { get { return customMaterialOverride; } } - #endif +#endif [System.NonSerialized] readonly Dictionary customSlotMaterials = new Dictionary(); /// Use this Dictionary to use a different Material to render specific Slots. @@ -314,18 +314,18 @@ namespace Spine.Unity { updateMode = updateWhenInvisible; } - #if UNITY_EDITOR && CONFIGURABLE_ENTER_PLAY_MODE +#if UNITY_EDITOR && CONFIGURABLE_ENTER_PLAY_MODE public virtual void Start () { Initialize(false); } - #endif +#endif - #if UNITY_EDITOR +#if UNITY_EDITOR void OnEnable() { if (!Application.isPlaying) LateUpdate(); } - #endif +#endif void OnDisable () { if (clearStateOnDisable && valid) @@ -407,13 +407,13 @@ namespace Spine.Unity { if (OnRebuild != null) OnRebuild(this); - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) { string errorMessage = null; if (!quiet && MaterialChecks.IsMaterialSetupProblematic(this, ref errorMessage)) Debug.LogWarningFormat(this, "Problematic material setup at {0}: {1}", this.name, errorMessage); } - #endif +#endif } /// @@ -421,7 +421,7 @@ namespace Spine.Unity { public virtual void LateUpdate () { if (!valid) return; - #if UNITY_EDITOR && NEW_PREFAB_SYSTEM +#if UNITY_EDITOR && NEW_PREFAB_SYSTEM // Don't store mesh or material at the prefab, otherwise it will permanently reload var prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(this); if (UnityEditor.PrefabUtility.IsPartOfPrefabAsset(this) && @@ -429,7 +429,7 @@ namespace Spine.Unity { return; } EditorUpdateMeshFilterHideFlags(); - #endif +#endif if (updateMode != UpdateMode.FullUpdate) return; @@ -455,10 +455,10 @@ namespace Spine.Unity { MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, skeletonDataAsset.atlasAssets[0].PrimaryMaterial); // STEP 1.9. Post-process workingInstructions. ================================================================================== - #if SPINE_OPTIONAL_MATERIALOVERRIDE +#if SPINE_OPTIONAL_MATERIALOVERRIDE if (customMaterialOverride.Count > 0) // isCustomMaterialOverridePopulated MeshGenerator.TryReplaceMaterials(workingSubmeshInstructions, customMaterialOverride); - #endif +#endif // STEP 2. Update vertex buffer based on verts from the attachments. =========================================================== meshGenerator.settings = new MeshGenerator.Settings { @@ -538,17 +538,17 @@ namespace Spine.Unity { meshFilter.sharedMesh = currentMesh; currentSmartMesh.instructionUsed.Set(currentInstructions); - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT if (meshRenderer != null) { AssignSpriteMaskMaterials(); } - #endif +#endif - #if PER_MATERIAL_PROPERTY_BLOCKS +#if PER_MATERIAL_PROPERTY_BLOCKS if (fixDrawOrder && meshRenderer.sharedMaterials.Length > 2) { SetMaterialSettingsToFixDrawOrder(); } - #endif +#endif if (OnMeshAndMaterialsUpdated != null) OnMeshAndMaterialsUpdated(this); @@ -616,23 +616,23 @@ namespace Spine.Unity { if (slot != null) { separatorSlots.Add(slot); } - #if UNITY_EDITOR +#if UNITY_EDITOR else if (!string.IsNullOrEmpty(separatorSlotNames[i])) { Debug.LogWarning(separatorSlotNames[i] + " is not a slot in " + skeletonDataAsset.skeletonJSON.name); } - #endif +#endif } } - #if BUILT_IN_SPRITE_MASK_COMPONENT +#if BUILT_IN_SPRITE_MASK_COMPONENT private void AssignSpriteMaskMaterials() { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying && !UnityEditor.EditorApplication.isUpdating) { EditorFixStencilCompParameters(); } - #endif +#endif if (Application.isPlaying) { if (maskInteraction != SpriteMaskInteraction.None && maskMaterials.materialsMaskDisabled.Length == 0) @@ -671,11 +671,11 @@ namespace Spine.Unity { private bool InitSpriteMaskMaterialsForMaskType(UnityEngine.Rendering.CompareFunction maskFunction, ref Material[] materialsToFill) { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) { return false; } - #endif +#endif var originalMaterials = maskMaterials.materialsMaskDisabled; materialsToFill = new Material[originalMaterials.Length]; @@ -687,7 +687,7 @@ namespace Spine.Unity { return true; } - #if UNITY_EDITOR +#if UNITY_EDITOR private void EditorFixStencilCompParameters() { if (!haveStencilParametersBeenFixed && HasAnyStencilComp0Material()) { haveStencilParametersBeenFixed = true; @@ -723,11 +723,11 @@ namespace Spine.Unity { } return false; } - #endif // UNITY_EDITOR +#endif // UNITY_EDITOR - #endif //#if BUILT_IN_SPRITE_MASK_COMPONENT +#endif //#if BUILT_IN_SPRITE_MASK_COMPONENT - #if PER_MATERIAL_PROPERTY_BLOCKS +#if PER_MATERIAL_PROPERTY_BLOCKS private MaterialPropertyBlock reusedPropertyBlock; public static readonly int SUBMESH_DUMMY_PARAM_ID = Shader.PropertyToID("_Submesh"); @@ -758,6 +758,6 @@ namespace Spine.Unity { meshRenderer.sharedMaterials[i].enableInstancing = false; } } - #endif +#endif } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonGraphicCustomMaterials.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonGraphicCustomMaterials.cs index afbb84b2c..2affc4426 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonGraphicCustomMaterials.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonGraphicCustomMaterials.cs @@ -36,11 +36,11 @@ using System.Collections.Generic; using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonGraphicCustomMaterials")] public class SkeletonGraphicCustomMaterials : MonoBehaviour { @@ -49,7 +49,7 @@ namespace Spine.Unity { [SerializeField] protected List customMaterialOverrides = new List(); [SerializeField] protected List customTextureOverrides = new List(); - #if UNITY_EDITOR +#if UNITY_EDITOR void Reset () { skeletonGraphic = GetComponent(); @@ -89,7 +89,7 @@ namespace Spine.Unity { customTextureOverrides = initialAtlasTextureOverrides; } } - #endif +#endif #endregion void SetCustomMaterialOverrides () { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonRendererCustomMaterials.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonRendererCustomMaterials.cs index c137570be..a8cd8ce5a 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonRendererCustomMaterials.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRendererCustomMaterials/SkeletonRendererCustomMaterials.cs @@ -39,11 +39,11 @@ using System.Collections.Generic; using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonRendererCustomMaterials")] public class SkeletonRendererCustomMaterials : MonoBehaviour { @@ -52,7 +52,7 @@ namespace Spine.Unity { [SerializeField] protected List customSlotMaterials = new List(); [SerializeField] protected List customMaterialOverrides = new List(); - #if UNITY_EDITOR +#if UNITY_EDITOR void Reset () { skeletonRenderer = GetComponent(); @@ -75,7 +75,7 @@ namespace Spine.Unity { customMaterialOverrides = initialAtlasMaterialOverrides; } } - #endif +#endif #endregion void SetCustomSlotMaterials () { @@ -125,7 +125,7 @@ namespace Spine.Unity { return; } - #if SPINE_OPTIONAL_MATERIALOVERRIDE +#if SPINE_OPTIONAL_MATERIALOVERRIDE for (int i = 0; i < customMaterialOverrides.Count; i++) { AtlasMaterialOverride atlasMaterialOverride = customMaterialOverrides[i]; if (atlasMaterialOverride.overrideDisabled) @@ -133,7 +133,7 @@ namespace Spine.Unity { skeletonRenderer.CustomMaterialOverride[atlasMaterialOverride.originalMaterial] = atlasMaterialOverride.replacementMaterial; } - #endif +#endif } void RemoveCustomMaterialOverrides () { @@ -142,7 +142,7 @@ namespace Spine.Unity { return; } - #if SPINE_OPTIONAL_MATERIALOVERRIDE +#if SPINE_OPTIONAL_MATERIALOVERRIDE for (int i = 0; i < customMaterialOverrides.Count; i++) { AtlasMaterialOverride atlasMaterialOverride = customMaterialOverrides[i]; Material currentMaterial; @@ -156,7 +156,7 @@ namespace Spine.Unity { skeletonRenderer.CustomMaterialOverride.Remove(atlasMaterialOverride.originalMaterial); } - #endif +#endif } // OnEnable applies the overrides at runtime, and when the editor loads. diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody.cs index f0ede08ee..b0601e3a3 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody.cs @@ -38,7 +38,7 @@ namespace Spine.Unity { /// [RequireComponent(typeof(Rigidbody))] public class FollowLocationRigidbody : MonoBehaviour { - + public Transform reference; Rigidbody ownRigidbody; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody2D.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody2D.cs index 76c12b99d..93d0ee9a1 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody2D.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowLocationRigidbody2D.cs @@ -38,7 +38,7 @@ namespace Spine.Unity { /// [RequireComponent(typeof(Rigidbody2D))] public class FollowLocationRigidbody2D : MonoBehaviour { - + public Transform reference; public bool followFlippedX; Rigidbody2D ownRigidbody; @@ -50,8 +50,7 @@ namespace Spine.Unity { void FixedUpdate () { if (followFlippedX) { ownRigidbody.rotation = ((-reference.rotation.eulerAngles.z + 270f) % 360f) - 90f; - } - else + } else ownRigidbody.rotation = reference.rotation.eulerAngles.z; ownRigidbody.position = reference.position; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowSkeletonUtilityRootRotation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowSkeletonUtilityRootRotation.cs index a970ae98d..143546a43 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowSkeletonUtilityRootRotation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/FollowSkeletonUtilityRootRotation.cs @@ -40,7 +40,7 @@ namespace Spine.Unity { /// do not attempt to use this component for other purposes. /// public class FollowSkeletonUtilityRootRotation : MonoBehaviour { - + const float FLIP_ANGLE_THRESHOLD = 100.0f; public Transform reference; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs index 632b85d7c..9860ea3df 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs @@ -31,16 +31,16 @@ #define NEW_PREFAB_SYSTEM #endif -using UnityEngine; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [RequireComponent(typeof(ISkeletonAnimation))] [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonUtility")] public sealed class SkeletonUtility : MonoBehaviour { @@ -74,7 +74,7 @@ namespace Spine.Unity { #if UNITY_EDITOR if (!Application.isPlaying) UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Spawn BoundingBox"); -# endif +#endif var got = go.transform; got.parent = parent; got.localPosition = Vector3.zero; @@ -152,8 +152,7 @@ namespace Spine.Unity { boneRoot.eulerAngles = new Vector3(skeleton.ScaleY > 0 ? 0 : 180, skeleton.ScaleX > 0 ? 0 : 180, 0); - } - else { + } else { boneRoot.localScale = new Vector3(skeleton.ScaleX, skeleton.ScaleY, 1f); } } @@ -231,8 +230,7 @@ namespace Spine.Unity { if (skeletonRenderer != null) { skeletonRenderer.OnRebuild -= HandleRendererReset; skeletonRenderer.OnRebuild += HandleRendererReset; - } - else if (skeletonGraphic != null) { + } else if (skeletonGraphic != null) { skeletonGraphic.OnRebuild -= HandleRendererReset; skeletonGraphic.OnRebuild += HandleRendererReset; canvas = skeletonGraphic.canvas; @@ -433,10 +431,10 @@ namespace Spine.Unity { public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) { GameObject go = new GameObject(bone.Data.Name); - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Spawn Bone"); - #endif +#endif if (skeletonGraphic != null) go.AddComponent(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityBone.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityBone.cs index db59a46d1..e39c001ba 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityBone.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityBone.cs @@ -35,11 +35,11 @@ using UnityEngine; namespace Spine.Unity { /// Sets a GameObject's transform to match a bone on a Spine skeleton. - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [AddComponentMenu("Spine/SkeletonUtilityBone")] [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonUtilityBone")] public class SkeletonUtilityBone : MonoBehaviour { @@ -128,43 +128,43 @@ namespace Spine.Unity { float skeletonFlipRotation = Mathf.Sign(skeleton.ScaleX * skeleton.ScaleY); if (mode == Mode.Follow) { switch (phase) { - case UpdatePhase.Local: - if (position) - thisTransform.localPosition = new Vector3(bone.x * positionScale, bone.y * positionScale, 0); + case UpdatePhase.Local: + if (position) + thisTransform.localPosition = new Vector3(bone.x * positionScale, bone.y * positionScale, 0); - if (rotation) { - if (bone.data.transformMode.InheritsRotation()) { - thisTransform.localRotation = Quaternion.Euler(0, 0, bone.rotation); - } else { - Vector3 euler = skeletonTransform.rotation.eulerAngles; - thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation)); - } + if (rotation) { + if (bone.data.transformMode.InheritsRotation()) { + thisTransform.localRotation = Quaternion.Euler(0, 0, bone.rotation); + } else { + Vector3 euler = skeletonTransform.rotation.eulerAngles; + thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation)); } + } - if (scale) { - thisTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, 1f); - incompatibleTransformMode = BoneTransformModeIncompatible(bone); - } - break; - case UpdatePhase.World: - case UpdatePhase.Complete: - if (position) - thisTransform.localPosition = new Vector3(bone.ax * positionScale, bone.ay * positionScale, 0); + if (scale) { + thisTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, 1f); + incompatibleTransformMode = BoneTransformModeIncompatible(bone); + } + break; + case UpdatePhase.World: + case UpdatePhase.Complete: + if (position) + thisTransform.localPosition = new Vector3(bone.ax * positionScale, bone.ay * positionScale, 0); - if (rotation) { - if (bone.data.transformMode.InheritsRotation()) { - thisTransform.localRotation = Quaternion.Euler(0, 0, bone.AppliedRotation); - } else { - Vector3 euler = skeletonTransform.rotation.eulerAngles; - thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation)); - } + if (rotation) { + if (bone.data.transformMode.InheritsRotation()) { + thisTransform.localRotation = Quaternion.Euler(0, 0, bone.AppliedRotation); + } else { + Vector3 euler = skeletonTransform.rotation.eulerAngles; + thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation)); } + } - if (scale) { - thisTransform.localScale = new Vector3(bone.ascaleX, bone.ascaleY, 1f); - incompatibleTransformMode = BoneTransformModeIncompatible(bone); - } - break; + if (scale) { + thisTransform.localScale = new Vector3(bone.ascaleX, bone.ascaleY, 1f); + incompatibleTransformMode = BoneTransformModeIncompatible(bone); + } + break; } } else if (mode == Mode.Override) { @@ -233,6 +233,6 @@ namespace Spine.Unity { if (IncompatibleTransformMode) Gizmos.DrawIcon(transform.position + new Vector3(0, 0.128f, 0), "icon-warning"); } - #endif +#endif } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityConstraint.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityConstraint.cs index f549afaa7..2f7c2eaf1 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityConstraint.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityConstraint.cs @@ -35,11 +35,11 @@ using UnityEngine; namespace Spine.Unity { - #if NEW_PREFAB_SYSTEM +#if NEW_PREFAB_SYSTEM [ExecuteAlways] - #else +#else [ExecuteInEditMode] - #endif +#endif [RequireComponent(typeof(SkeletonUtilityBone))] [HelpURL("http://esotericsoftware.com/spine-unity#SkeletonUtilityConstraint")] public abstract class SkeletonUtilityConstraint : MonoBehaviour { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs index 5ac0c5c03..ad026500c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs @@ -35,9 +35,9 @@ #define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame. //#define SPINE_DEBUG -using UnityEngine; using System; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { public delegate void MeshGeneratorDelegate (MeshGeneratorBuffers buffers); @@ -156,25 +156,25 @@ namespace Spine.Unity { instructionOutput.Clear(); // submeshInstructions.Clear(); attachments.Clear(); var workingSubmeshInstructions = instructionOutput.submeshInstructions; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK instructionOutput.attachments.Resize(drawOrderCount); var workingAttachmentsItems = instructionOutput.attachments.Items; int totalRawVertexCount = 0; - #endif +#endif var current = new SubmeshInstruction { skeleton = skeleton, preActiveClippingSlotSource = -1, startSlot = 0, - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK rawFirstVertexIndex = 0, - #endif +#endif material = material, forceSeparate = false, endSlot = drawOrderCount }; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK object rendererObject = null; bool skeletonHasClipping = false; var drawOrderItems = drawOrder.Items; @@ -214,32 +214,31 @@ namespace Spine.Unity { totalRawVertexCount += attachmentVertexCount; } - #if !SPINE_TK2D +#if !SPINE_TK2D if (material == null && rendererObject != null) current.material = (Material)((AtlasRegion)rendererObject).page.rendererObject; - #else +#else if (material == null && rendererObject != null) current.material = (rendererObject is Material) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; - #endif +#endif instructionOutput.hasActiveClipping = skeletonHasClipping; instructionOutput.rawVertexCount = totalRawVertexCount; - #endif +#endif if (totalRawVertexCount > 0) { workingSubmeshInstructions.Resize(1); workingSubmeshInstructions.Items[0] = current; - } - else { + } else { workingSubmeshInstructions.Resize(0); } } public static bool RequiresMultipleSubmeshesByDrawOrder (Skeleton skeleton) { - #if SPINE_TK2D +#if SPINE_TK2D return false; - #endif +#endif ExposedList drawOrder = skeleton.drawOrder; int drawOrderCount = drawOrder.Count; var drawOrderItems = drawOrder.Items; @@ -274,21 +273,21 @@ namespace Spine.Unity { // Clear last state of attachments and submeshes instructionOutput.Clear(); // submeshInstructions.Clear(); attachments.Clear(); var workingSubmeshInstructions = instructionOutput.submeshInstructions; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK instructionOutput.attachments.Resize(drawOrderCount); var workingAttachmentsItems = instructionOutput.attachments.Items; int totalRawVertexCount = 0; bool skeletonHasClipping = false; - #endif +#endif var current = new SubmeshInstruction { skeleton = skeleton, preActiveClippingSlotSource = -1 }; - #if !SPINE_TK2D +#if !SPINE_TK2D bool isCustomSlotMaterialsPopulated = customSlotMaterials != null && customSlotMaterials.Count > 0; - #endif +#endif int separatorCount = separatorSlots == null ? 0 : separatorSlots.Count; bool hasSeparators = separatorCount > 0; @@ -303,10 +302,10 @@ namespace Spine.Unity { if (!slot.bone.active) continue; if (slot.data.blendMode == BlendMode.Additive) current.hasPMAAdditiveSlot = true; Attachment attachment = slot.attachment; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK workingAttachmentsItems[i] = attachment; int attachmentVertexCount = 0, attachmentTriangleCount = 0; - #endif +#endif object rendererObject = null; // An AtlasRegion in plain Spine-Unity. Spine-TK2D hooks into TK2D's system. eventual source of Material object. bool noRender = false; // Using this allows empty slots as separators, and keeps separated parts more stable despite slots being reordered @@ -314,20 +313,20 @@ namespace Spine.Unity { var regionAttachment = attachment as RegionAttachment; if (regionAttachment != null) { rendererObject = regionAttachment.RendererObject; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK attachmentVertexCount = 4; attachmentTriangleCount = 6; - #endif +#endif } else { var meshAttachment = attachment as MeshAttachment; if (meshAttachment != null) { rendererObject = meshAttachment.RendererObject; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK attachmentVertexCount = meshAttachment.worldVerticesLength >> 1; attachmentTriangleCount = meshAttachment.triangles.Length; - #endif +#endif } else { - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK var clippingAttachment = attachment as ClippingAttachment; if (clippingAttachment != null) { clippingEndSlot = clippingAttachment.endSlot; @@ -335,7 +334,7 @@ namespace Spine.Unity { current.hasClipping = true; skeletonHasClipping = true; } - #endif +#endif noRender = true; } } @@ -366,15 +365,15 @@ namespace Spine.Unity { current.startSlot = i; lastPreActiveClipping = clippingAttachmentSource; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK current.rawTriangleCount = 0; current.rawVertexCount = 0; current.rawFirstVertexIndex = totalRawVertexCount; current.hasClipping = clippingAttachmentSource >= 0; - #endif +#endif } } else { - #if !SPINE_TK2D +#if !SPINE_TK2D Material material; if (isCustomSlotMaterialsPopulated) { if (!customSlotMaterials.TryGetValue(slot, out material)) @@ -382,9 +381,9 @@ namespace Spine.Unity { } else { material = (Material)((AtlasRegion)rendererObject).page.rendererObject; } - #else +#else Material material = (rendererObject is Material) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; - #endif +#endif if (current.forceSeparate || (current.rawVertexCount > 0 && !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh. { // Add @@ -397,22 +396,22 @@ namespace Spine.Unity { } current.startSlot = i; lastPreActiveClipping = clippingAttachmentSource; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK current.rawTriangleCount = 0; current.rawVertexCount = 0; current.rawFirstVertexIndex = totalRawVertexCount; current.hasClipping = clippingAttachmentSource >= 0; - #endif +#endif } // Update state for the next Attachment. current.material = material; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK current.rawTriangleCount += attachmentTriangleCount; current.rawVertexCount += attachmentVertexCount; current.rawFirstVertexIndex = totalRawVertexCount; totalRawVertexCount += attachmentVertexCount; - #endif +#endif } if (clippingEndSlot != null && slot.data == clippingEndSlot && i != clippingAttachmentSource) { @@ -433,10 +432,10 @@ namespace Spine.Unity { } } - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK instructionOutput.hasActiveClipping = skeletonHasClipping; instructionOutput.rawVertexCount = totalRawVertexCount; - #endif +#endif instructionOutput.immutableTriangles = immutableTriangles; } @@ -497,11 +496,11 @@ namespace Spine.Unity { float zSpacing = settings.zSpacing; bool pmaVertexColors = settings.pmaVertexColors; bool tintBlack = settings.tintBlack; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK bool useClipping = settings.useClipping && instruction.hasClipping; - #else +#else bool useClipping = settings.useClipping; - #endif +#endif bool canvasGroupTintBlack = settings.tintBlack && settings.canvasGroupTintBlack; if (useClipping) { @@ -578,8 +577,7 @@ namespace Spine.Unity { tintBlackAlpha = 0; else color.a = 0; - } - else if (canvasGroupTintBlack) { // other blend modes + } else if (canvasGroupTintBlack) { // other blend modes tintBlackAlpha = colorA; } } else { @@ -831,7 +829,7 @@ namespace Spine.Unity { vbi[vertexIndex].x = x1; vbi[vertexIndex].y = y1; vbi[vertexIndex].z = z; vbi[vertexIndex + 1].x = x4; vbi[vertexIndex + 1].y = y4; vbi[vertexIndex + 1].z = z; vbi[vertexIndex + 2].x = x2; vbi[vertexIndex + 2].y = y2; vbi[vertexIndex + 2].z = z; - vbi[vertexIndex + 3].x = x3; vbi[vertexIndex + 3].y = y3; vbi[vertexIndex + 3].z = z; + vbi[vertexIndex + 3].x = x3; vbi[vertexIndex + 3].y = y3; vbi[vertexIndex + 3].z = z; if (settings.pmaVertexColors) { color.a = (byte)(a * slot.a * regionAttachment.a * 255); @@ -1255,7 +1253,7 @@ namespace Spine.Unity { // t.Normalize() (aggressively inlined). Even better if offloaded to GPU via vertex shader. float magnitude = Mathf.Sqrt(t.x * t.x + t.y * t.y); if (magnitude > 1E-05) { - float reciprocalMagnitude = 1f/magnitude; + float reciprocalMagnitude = 1f / magnitude; t.x *= reciprocalMagnitude; t.y *= reciprocalMagnitude; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshRendererBuffers.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshRendererBuffers.cs index e108bbda9..7402e5884 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshRendererBuffers.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshRendererBuffers.cs @@ -31,9 +31,9 @@ #define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame. //#define SPINE_DEBUG -using UnityEngine; using System; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { /// A double-buffered Mesh, and a shared material array, bundled for use by Spine components that need to push a Mesh and materials to a Unity MeshRenderer and MeshFilter. @@ -119,14 +119,14 @@ namespace Spine.Unity { public void Dispose () { if (mesh != null) { - #if UNITY_EDITOR +#if UNITY_EDITOR if (Application.isEditor && !Application.isPlaying) UnityEngine.Object.DestroyImmediate(mesh); else UnityEngine.Object.Destroy(mesh); - #else +#else UnityEngine.Object.Destroy(mesh); - #endif +#endif } mesh = null; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SkeletonRendererInstruction.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SkeletonRendererInstruction.cs index 54821fa5f..048178600 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SkeletonRendererInstruction.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SkeletonRendererInstruction.cs @@ -31,9 +31,9 @@ #define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame. //#define SPINE_DEBUG -using UnityEngine; using System; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { /// Instructions used by a SkeletonRenderer to render a mesh. @@ -41,18 +41,18 @@ namespace Spine.Unity { public readonly ExposedList submeshInstructions = new ExposedList(); public bool immutableTriangles; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK public bool hasActiveClipping; public int rawVertexCount = -1; public readonly ExposedList attachments = new ExposedList(); - #endif +#endif public void Clear () { - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK this.attachments.Clear(false); rawVertexCount = -1; hasActiveClipping = false; - #endif +#endif this.submeshInstructions.Clear(false); } @@ -61,9 +61,9 @@ namespace Spine.Unity { } public void SetWithSubset (ExposedList instructions, int startSubmesh, int endSubmesh) { - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK int runningVertexCount = 0; - #endif +#endif var submeshes = this.submeshInstructions; submeshes.Clear(false); @@ -74,13 +74,13 @@ namespace Spine.Unity { for (int i = 0; i < submeshCount; i++) { var instruction = instructionsItems[startSubmesh + i]; submeshesItems[i] = instruction; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK this.hasActiveClipping |= instruction.hasClipping; submeshesItems[i].rawFirstVertexIndex = runningVertexCount; // Ensure current instructions have correct cached values. runningVertexCount += instruction.rawVertexCount; // vertexCount will also be used for the rest of this method. - #endif +#endif } - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK this.rawVertexCount = runningVertexCount; // assumption: instructions are contiguous. start and end are valid within instructions. @@ -99,20 +99,20 @@ namespace Spine.Unity { attachmentsItems[i] = slot.attachment; } - #endif +#endif } public void Set (SkeletonRendererInstruction other) { this.immutableTriangles = other.immutableTriangles; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK this.hasActiveClipping = other.hasActiveClipping; this.rawVertexCount = other.rawVertexCount; this.attachments.Clear(false); this.attachments.EnsureCapacity(other.attachments.Capacity); this.attachments.Count = other.attachments.Count; other.attachments.CopyTo(this.attachments.Items); - #endif +#endif this.submeshInstructions.Clear(false); this.submeshInstructions.EnsureCapacity(other.submeshInstructions.Capacity); @@ -121,11 +121,11 @@ namespace Spine.Unity { } public static bool GeometryNotEqual (SkeletonRendererInstruction a, SkeletonRendererInstruction b) { - #if SPINE_TRIANGLECHECK - #if UNITY_EDITOR +#if SPINE_TRIANGLECHECK +#if UNITY_EDITOR if (!Application.isPlaying) return true; - #endif +#endif if (a.hasActiveClipping || b.hasActiveClipping) return true; // Triangles are unpredictable when clipping is active. @@ -166,13 +166,13 @@ namespace Spine.Unity { } return false; - #else +#else // In normal immutable triangle use, immutableTriangles will be initially false, forcing the smartmesh to update the first time but never again after that, unless there was an immutableTriangles flag mismatch.. if (a.immutableTriangles || b.immutableTriangles) return (a.immutableTriangles != b.immutableTriangles); return true; - #endif +#endif } } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs index ce5b15260..845b7d0df 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs @@ -31,9 +31,9 @@ #define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame. //#define SPINE_DEBUG -using UnityEngine; using System; using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity { public static class SpineMesh { @@ -59,14 +59,14 @@ namespace Spine.Unity { public bool forceSeparate; public int preActiveClippingSlotSource; - #if SPINE_TRIANGLECHECK +#if SPINE_TRIANGLECHECK // Cached values because they are determined in the process of generating instructions, // but could otherwise be pulled from accessing attachments, checking materials and counting tris and verts. public int rawTriangleCount; public int rawVertexCount; public int rawFirstVertexIndex; public bool hasClipping; - #endif +#endif public bool hasPMAAdditiveSlot; /// The number of slots in this SubmeshInstruction's range. Not necessarily the number of attachments. diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonDataModifierAssets/BlendModeMaterials/BlendModeMaterialsAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonDataModifierAssets/BlendModeMaterials/BlendModeMaterialsAsset.cs index 3f649324b..61f861c1a 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonDataModifierAssets/BlendModeMaterials/BlendModeMaterialsAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonDataModifierAssets/BlendModeMaterials/BlendModeMaterialsAsset.cs @@ -27,14 +27,13 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; +using Spine.Unity; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; -using Spine; -using Spine.Unity; - namespace Spine.Unity { [CreateAssetMenu(menuName = "Spine/SkeletonData Modifiers/Blend Mode Materials", order = 200)] public class BlendModeMaterialsAsset : SkeletonDataModifierAsset { @@ -65,15 +64,15 @@ namespace Spine.Unity { Material templateMaterial = null; switch (slot.blendMode) { - case BlendMode.Multiply: - templateMaterial = multiplyTemplate; - break; - case BlendMode.Screen: - templateMaterial = screenTemplate; - break; - case BlendMode.Additive: - templateMaterial = additiveTemplate; - break; + case BlendMode.Multiply: + templateMaterial = multiplyTemplate; + break; + case BlendMode.Screen: + templateMaterial = screenTemplate; + break; + case BlendMode.Additive: + templateMaterial = additiveTemplate; + break; } if (templateMaterial == null) continue; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs index a0dd2e276..678def405 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SpineAttributes.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; using System; using System.Collections; +using UnityEngine; namespace Spine.Unity { @@ -267,14 +267,13 @@ namespace Spine.Unity { public string name; public Hierarchy (string fullPath) { - string[] chunks = fullPath.Split(new char[]{'/'}, System.StringSplitOptions.RemoveEmptyEntries); + string[] chunks = fullPath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); if (chunks.Length == 0) { skin = ""; slot = ""; name = ""; return; - } - else if (chunks.Length < 2) { + } else if (chunks.Length < 2) { throw new System.Exception("Cannot generate Attachment Hierarchy from string! Not enough components! [" + fullPath + "]"); } skin = chunks[0]; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs index b8c2eb2a4..074946b41 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs @@ -32,9 +32,9 @@ #endif -using UnityEngine; -using System.Collections.Generic; using System; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.AttachmentTools { @@ -47,13 +47,13 @@ namespace Spine.Unity.AttachmentTools { const int NonrenderingRegion = -1; - #if CONFIGURABLE_ENTER_PLAY_MODE +#if CONFIGURABLE_ENTER_PLAY_MODE [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] static void Init () { // handle disabled domain reload AtlasUtilities.ClearCache(); } - #endif +#endif public static AtlasRegion ToAtlasRegion (this Texture2D t, Material materialPropertySource, float scale = DefaultScale) { return t.ToAtlasRegion(materialPropertySource.shader, scale, materialPropertySource); @@ -113,7 +113,7 @@ namespace Spine.Unity.AttachmentTools { material.CopyPropertiesFromMaterial(materialPropertySource); material.shaderKeywords = materialPropertySource.shaderKeywords; } - var newTexture = t.GetClone(textureFormat, mipmaps, applyPMA : true); + var newTexture = t.GetClone(textureFormat, mipmaps, applyPMA: true); newTexture.name = t.name + "-pma-"; material.name = t.name + shader.name; @@ -174,7 +174,7 @@ namespace Spine.Unity.AttachmentTools { material.shaderKeywords = materialPropertySource.shaderKeywords; } - var tex = s.ToTexture(textureFormat, mipmaps, applyPMA : true); + var tex = s.ToTexture(textureFormat, mipmaps, applyPMA: true); tex.name = s.name + "-pma-"; material.name = tex.name + shader.name; @@ -358,8 +358,7 @@ namespace Spine.Unity.AttachmentTools { int existingIndex; if (existingRegions.TryGetValue(region, out existingIndex)) { regionIndices.Add(existingIndex); - } - else { + } else { originalRegions.Add(region); for (int i = 0; i < numTextureParamsToRepack; ++i) { Texture2D regionTexture = (i == 0 ? @@ -376,8 +375,7 @@ namespace Spine.Unity.AttachmentTools { } outputAttachments[attachmentIndex] = newAttachment; - } - else { + } else { outputAttachments[attachmentIndex] = useOriginalNonrenderables ? originalAttachment : originalAttachment.Copy(); regionIndices.Add(NonrenderingRegion); // Output attachments pairs with regionIndices list 1:1. Pad with a sentinel if the attachment doesn't have a region. } @@ -412,8 +410,7 @@ namespace Spine.Unity.AttachmentTools { rects = rectsForTexParam; newMaterial.mainTexture = newTexture; outputTexture = newTexture; - } - else { + } else { newMaterial.SetTexture(additionalTexturePropertyIDsToCopy[i - 1], newTexture); additionalOutputTextures[i - 1] = newTexture; } @@ -526,7 +523,7 @@ namespace Spine.Unity.AttachmentTools { int i; AtlasRegion region; - public IntAndAtlasRegionKey(int i, AtlasRegion region) { + public IntAndAtlasRegionKey (int i, AtlasRegion region) { this.i = i; this.region = region; } @@ -592,20 +589,19 @@ namespace Spine.Unity.AttachmentTools { Rect r; if (!s.packed || s.packingMode == SpritePackingMode.Rectangle) { r = s.textureRect; - } - else { + } else { r = new Rect(); r.xMin = Math.Min(s.uv[0].x, s.uv[1].x) * spriteTexture.width; r.xMax = Math.Max(s.uv[0].x, s.uv[1].x) * spriteTexture.width; r.yMin = Math.Min(s.uv[0].y, s.uv[2].y) * spriteTexture.height; r.yMax = Math.Max(s.uv[0].y, s.uv[2].y) * spriteTexture.height; - #if UNITY_EDITOR +#if UNITY_EDITOR if (s.uv.Length > 4) { Debug.LogError("When using a tightly packed SpriteAtlas with Spine, you may only access Sprites that are packed as 'FullRect' from it! " + "You can either disable 'Tight Packing' at the whole SpriteAtlas, or change the single Sprite's TextureImporter Setting 'MeshType' to 'Full Rect'." + "Sprite Asset: " + s.name, s); } - #endif +#endif } var newTexture = new Texture2D((int)r.width, (int)r.height, textureFormat, mipmaps, linear); newTexture.CopyTextureAttributesFrom(spriteTexture); @@ -635,7 +631,7 @@ namespace Spine.Unity.AttachmentTools { destination.SetPixels(pixelBuffer); destination.Apply(); } else { - Graphics.CopyTexture(source, 0, 0, (int)sourceRect.x, (int)sourceRect.y, (int)sourceRect.width, (int)sourceRect.height, destination, 0, 0, 0, 0); + Graphics.CopyTexture(source, 0, 0, (int)sourceRect.x, (int)sourceRect.y, (int)sourceRect.width, (int)sourceRect.height, destination, 0, 0, 0, 0); } } @@ -783,12 +779,12 @@ namespace Spine.Unity.AttachmentTools { return material.GetTexture(texturePropertyId) as Texture2D; } - static void CopyTextureAttributesFrom(this Texture2D destination, Texture2D source) { + static void CopyTextureAttributesFrom (this Texture2D destination, Texture2D source) { destination.filterMode = source.filterMode; destination.anisoLevel = source.anisoLevel; - #if UNITY_EDITOR +#if UNITY_EDITOR destination.alphaIsTransparency = source.alphaIsTransparency; - #endif +#endif destination.wrapModeU = source.wrapModeU; destination.wrapModeV = source.wrapModeV; destination.wrapModeW = source.wrapModeW; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs index e1db998cc..50f6421e9 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections.Generic; using System.Collections; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.AttachmentTools { @@ -59,7 +59,7 @@ namespace Spine.Unity.AttachmentTools { public static Attachment GetRemappedClone (this Attachment o, Sprite sprite, Material sourceMaterial, bool premultiplyAlpha = true, bool cloneMeshAsLinked = true, bool useOriginalRegionSize = false, bool pivotShiftsMeshUVCoords = true, bool useOriginalRegionScale = false) { - var atlasRegion = premultiplyAlpha ? sprite.ToAtlasRegionPMAClone(sourceMaterial) : sprite.ToAtlasRegion(new Material(sourceMaterial) { mainTexture = sprite.texture } ); + var atlasRegion = premultiplyAlpha ? sprite.ToAtlasRegionPMAClone(sourceMaterial) : sprite.ToAtlasRegion(new Material(sourceMaterial) { mainTexture = sprite.texture }); if (!pivotShiftsMeshUVCoords && o is MeshAttachment) { // prevent non-central sprite pivot setting offsetX/Y and shifting uv coords out of mesh bounds atlasRegion.offsetX = 0; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentRegionExtensions.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentRegionExtensions.cs index 7e6c65e45..c7e516173 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentRegionExtensions.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentRegionExtensions.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections.Generic; using System.Collections; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.AttachmentTools { public static class AttachmentRegionExtensions { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/SkeletonExtensions.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/SkeletonExtensions.cs index 48020800e..d84612f77 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/SkeletonExtensions.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/SkeletonExtensions.cs @@ -216,11 +216,11 @@ namespace Spine.Unity { if (rendererObject == null) return null; - #if SPINE_TK2D +#if SPINE_TK2D return (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; - #else +#else return (Material)((AtlasRegion)rendererObject).page.rendererObject; - #endif +#endif } /// Fills a Vector2 buffer with local vertices. @@ -237,7 +237,7 @@ namespace Spine.Unity { var localVerts = va.vertices; for (int i = 0; i < bufferTargetSize; i++) { int j = i * 2; - buffer[i] = new Vector2(localVerts[j], localVerts[j+1]); + buffer[i] = new Vector2(localVerts[j], localVerts[j + 1]); } } else { var floats = new float[floatsCount]; @@ -249,7 +249,7 @@ namespace Spine.Unity { for (int i = 0; i < bufferTargetSize; i++) { int j = i * 2; - float x = floats[j] - bwx, y = floats[j+1] - bwy; + float x = floats[j] - bwx, y = floats[j + 1] - bwy; buffer[i] = new Vector2(x * ia + y * ib, x * ic + y * id); } } @@ -327,78 +327,78 @@ namespace Spine { result.y = pc * boneData.x + pd * boneData.y + parentMatrix.y; switch (boneData.transformMode) { - case TransformMode.Normal: { - float rotationY = boneData.rotation + 90 + boneData.shearY; - float la = MathUtils.CosDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; - float lb = MathUtils.CosDeg(rotationY) * boneData.scaleY; - float lc = MathUtils.SinDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; - float ld = MathUtils.SinDeg(rotationY) * boneData.scaleY; - result.a = pa * la + pb * lc; - result.b = pa * lb + pb * ld; - result.c = pc * la + pd * lc; - result.d = pc * lb + pd * ld; - break; + case TransformMode.Normal: { + float rotationY = boneData.rotation + 90 + boneData.shearY; + float la = MathUtils.CosDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; + float lb = MathUtils.CosDeg(rotationY) * boneData.scaleY; + float lc = MathUtils.SinDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; + float ld = MathUtils.SinDeg(rotationY) * boneData.scaleY; + result.a = pa * la + pb * lc; + result.b = pa * lb + pb * ld; + result.c = pc * la + pd * lc; + result.d = pc * lb + pd * ld; + break; + } + case TransformMode.OnlyTranslation: { + float rotationY = boneData.rotation + 90 + boneData.shearY; + result.a = MathUtils.CosDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; + result.b = MathUtils.CosDeg(rotationY) * boneData.scaleY; + result.c = MathUtils.SinDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; + result.d = MathUtils.SinDeg(rotationY) * boneData.scaleY; + break; + } + case TransformMode.NoRotationOrReflection: { + float s = pa * pa + pc * pc, prx; + if (s > 0.0001f) { + s = Math.Abs(pa * pd - pb * pc) / s; + pb = pc * s; + pd = pa * s; + prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg; + } else { + pa = 0; + pc = 0; + prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg; } - case TransformMode.OnlyTranslation: { - float rotationY = boneData.rotation + 90 + boneData.shearY; - result.a = MathUtils.CosDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; - result.b = MathUtils.CosDeg(rotationY) * boneData.scaleY; - result.c = MathUtils.SinDeg(boneData.rotation + boneData.shearX) * boneData.scaleX; - result.d = MathUtils.SinDeg(rotationY) * boneData.scaleY; - break; - } - case TransformMode.NoRotationOrReflection: { - float s = pa * pa + pc * pc, prx; - if (s > 0.0001f) { - s = Math.Abs(pa * pd - pb * pc) / s; - pb = pc * s; - pd = pa * s; - prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg; - } else { - pa = 0; - pc = 0; - prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg; - } - float rx = boneData.rotation + boneData.shearX - prx; - float ry = boneData.rotation + boneData.shearY - prx + 90; - float la = MathUtils.CosDeg(rx) * boneData.scaleX; - float lb = MathUtils.CosDeg(ry) * boneData.scaleY; - float lc = MathUtils.SinDeg(rx) * boneData.scaleX; - float ld = MathUtils.SinDeg(ry) * boneData.scaleY; - result.a = pa * la - pb * lc; - result.b = pa * lb - pb * ld; - result.c = pc * la + pd * lc; - result.d = pc * lb + pd * ld; - break; - } - case TransformMode.NoScale: - case TransformMode.NoScaleOrReflection: { - float cos = MathUtils.CosDeg(boneData.rotation), sin = MathUtils.SinDeg(boneData.rotation); - float za = pa * cos + pb * sin; - float zc = pc * cos + pd * sin; - float s = (float)Math.Sqrt(za * za + zc * zc); - if (s > 0.00001f) - s = 1 / s; - za *= s; - zc *= s; - s = (float)Math.Sqrt(za * za + zc * zc); - float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); - float zb = MathUtils.Cos(r) * s; - float zd = MathUtils.Sin(r) * s; - float la = MathUtils.CosDeg(boneData.shearX) * boneData.scaleX; - float lb = MathUtils.CosDeg(90 + boneData.shearY) * boneData.scaleY; - float lc = MathUtils.SinDeg(boneData.shearX) * boneData.scaleX; - float ld = MathUtils.SinDeg(90 + boneData.shearY) * boneData.scaleY; - if (boneData.transformMode != TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : false) { - zb = -zb; - zd = -zd; - } - result.a = za * la + zb * lc; - result.b = za * lb + zb * ld; - result.c = zc * la + zd * lc; - result.d = zc * lb + zd * ld; - break; + float rx = boneData.rotation + boneData.shearX - prx; + float ry = boneData.rotation + boneData.shearY - prx + 90; + float la = MathUtils.CosDeg(rx) * boneData.scaleX; + float lb = MathUtils.CosDeg(ry) * boneData.scaleY; + float lc = MathUtils.SinDeg(rx) * boneData.scaleX; + float ld = MathUtils.SinDeg(ry) * boneData.scaleY; + result.a = pa * la - pb * lc; + result.b = pa * lb - pb * ld; + result.c = pc * la + pd * lc; + result.d = pc * lb + pd * ld; + break; + } + case TransformMode.NoScale: + case TransformMode.NoScaleOrReflection: { + float cos = MathUtils.CosDeg(boneData.rotation), sin = MathUtils.SinDeg(boneData.rotation); + float za = pa * cos + pb * sin; + float zc = pc * cos + pd * sin; + float s = (float)Math.Sqrt(za * za + zc * zc); + if (s > 0.00001f) + s = 1 / s; + za *= s; + zc *= s; + s = (float)Math.Sqrt(za * za + zc * zc); + float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); + float zb = MathUtils.Cos(r) * s; + float zd = MathUtils.Sin(r) * s; + float la = MathUtils.CosDeg(boneData.shearX) * boneData.scaleX; + float lb = MathUtils.CosDeg(90 + boneData.shearY) * boneData.scaleY; + float lc = MathUtils.SinDeg(boneData.shearX) * boneData.scaleX; + float ld = MathUtils.SinDeg(90 + boneData.shearY) * boneData.scaleY; + if (boneData.transformMode != TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : false) { + zb = -zb; + zd = -zd; } + result.a = za * la + zb * lc; + result.b = za * lb + zb * ld; + result.c = zc * la + zd * lc; + result.d = zc * lb + zd * ld; + break; + } } return result; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/TimelineExtensions.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/TimelineExtensions.cs index 724e61502..49dcf25b7 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/TimelineExtensions.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/TimelineExtensions.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections.Generic; using System.Collections; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.AnimationTools { public static class TimelineExtensions { @@ -44,29 +44,28 @@ namespace Spine.Unity.AnimationTools { float x, y; int i = TranslateTimeline.Search(frames, time, TranslateTimeline.ENTRIES), curveType = (int)timeline.curves[i / TranslateTimeline.ENTRIES]; switch (curveType) { - case TranslateTimeline.LINEAR: - float before = frames[i]; - x = frames[i + TranslateTimeline.VALUE1]; - y = frames[i + TranslateTimeline.VALUE2]; - float t = (time - before) / (frames[i + TranslateTimeline.ENTRIES] - before); - x += (frames[i + TranslateTimeline.ENTRIES + TranslateTimeline.VALUE1] - x) * t; - y += (frames[i + TranslateTimeline.ENTRIES + TranslateTimeline.VALUE2] - y) * t; - break; - case TranslateTimeline.STEPPED: - x = frames[i + TranslateTimeline.VALUE1]; - y = frames[i + TranslateTimeline.VALUE2]; - break; - default: - x = timeline.GetBezierValue(time, i, TranslateTimeline.VALUE1, curveType - TranslateTimeline.BEZIER); - y = timeline.GetBezierValue(time, i, TranslateTimeline.VALUE2, curveType + TranslateTimeline.BEZIER_SIZE - TranslateTimeline.BEZIER); - break; + case TranslateTimeline.LINEAR: + float before = frames[i]; + x = frames[i + TranslateTimeline.VALUE1]; + y = frames[i + TranslateTimeline.VALUE2]; + float t = (time - before) / (frames[i + TranslateTimeline.ENTRIES] - before); + x += (frames[i + TranslateTimeline.ENTRIES + TranslateTimeline.VALUE1] - x) * t; + y += (frames[i + TranslateTimeline.ENTRIES + TranslateTimeline.VALUE2] - y) * t; + break; + case TranslateTimeline.STEPPED: + x = frames[i + TranslateTimeline.VALUE1]; + y = frames[i + TranslateTimeline.VALUE2]; + break; + default: + x = timeline.GetBezierValue(time, i, TranslateTimeline.VALUE1, curveType - TranslateTimeline.BEZIER); + y = timeline.GetBezierValue(time, i, TranslateTimeline.VALUE2, curveType + TranslateTimeline.BEZIER_SIZE - TranslateTimeline.BEZIER); + break; } Vector2 xy = new Vector2(x, y); if (skeletonData == null) { return xy; - } - else { + } else { var boneData = skeletonData.bones.Items[timeline.BoneIndex]; return xy + new Vector2(boneData.x, boneData.y); } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimation.cs index 644ceed9f..daa7171e1 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimation.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using System; +using System.Collections; +using UnityEngine; namespace Spine.Unity { /// @@ -43,8 +43,7 @@ namespace Spine.Unity { public class WaitForSpineAnimation : IEnumerator { [Flags] - public enum AnimationEventTypes - { + public enum AnimationEventTypes { Start = 1, Interrupt = 2, End = 4, @@ -71,7 +70,7 @@ namespace Spine.Unity { #region IEnumerator bool IEnumerator.MoveNext () { if (m_WasFired) { - ((IEnumerator)this).Reset(); // auto-reset for YieldInstruction reuse + ((IEnumerator)this).Reset(); // auto-reset for YieldInstruction reuse return false; } @@ -86,8 +85,7 @@ namespace Spine.Unity { // Break immediately if trackEntry is null. Debug.LogWarning("TrackEntry was null. Coroutine will continue immediately."); m_WasFired = true; - } - else { + } else { if ((eventsToWaitFor & AnimationEventTypes.Start) != 0) trackEntry.Start += HandleComplete; if ((eventsToWaitFor & AnimationEventTypes.Interrupt) != 0) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationComplete.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationComplete.cs index 39cf16a95..2714995e4 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationComplete.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationComplete.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine; +using System.Collections; +using UnityEngine; namespace Spine.Unity { /// @@ -44,8 +44,7 @@ namespace Spine.Unity { public WaitForSpineAnimationComplete (Spine.TrackEntry trackEntry, bool includeEndEvent = false) : base(trackEntry, - includeEndEvent ? (AnimationEventTypes.Complete | AnimationEventTypes.End) : AnimationEventTypes.Complete) - { + includeEndEvent ? (AnimationEventTypes.Complete | AnimationEventTypes.End) : AnimationEventTypes.Complete) { } #region Reuse diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationEnd.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationEnd.cs index dbafcc6c0..1f2548bb5 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationEnd.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineAnimationEnd.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine; +using System.Collections; +using UnityEngine; namespace Spine.Unity { /// @@ -42,8 +42,7 @@ namespace Spine.Unity { public class WaitForSpineAnimationEnd : WaitForSpineAnimation, IEnumerator { public WaitForSpineAnimationEnd (Spine.TrackEntry trackEntry) : - base(trackEntry, AnimationEventTypes.End) - { + base(trackEntry, AnimationEventTypes.End) { } #region Reuse diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineEvent.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineEvent.cs index 1da2bcb6a..ab477daee 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineEvent.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineEvent.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine; +using System.Collections; +using UnityEngine; namespace Spine.Unity { /// @@ -103,15 +103,15 @@ namespace Spine.Unity { #region Event Handlers void HandleAnimationStateEventByName (Spine.TrackEntry trackEntry, Spine.Event e) { - m_WasFired |= (e.Data.Name == m_EventName); // Check event name string match. + m_WasFired |= (e.Data.Name == m_EventName); // Check event name string match. if (m_WasFired && m_unsubscribeAfterFiring) - m_AnimationState.Event -= HandleAnimationStateEventByName; // Unsubscribe after correct event fires. + m_AnimationState.Event -= HandleAnimationStateEventByName; // Unsubscribe after correct event fires. } void HandleAnimationStateEvent (Spine.TrackEntry trackEntry, Spine.Event e) { - m_WasFired |= (e.Data == m_TargetEvent); // Check event data reference match. + m_WasFired |= (e.Data == m_TargetEvent); // Check event data reference match. if (m_WasFired && m_unsubscribeAfterFiring) - m_AnimationState.Event -= HandleAnimationStateEvent; // Usubscribe after correct event fires. + m_AnimationState.Event -= HandleAnimationStateEvent; // Usubscribe after correct event fires. } #endregion @@ -146,7 +146,7 @@ namespace Spine.Unity { #region IEnumerator bool IEnumerator.MoveNext () { if (m_WasFired) { - ((IEnumerator)this).Reset(); // auto-reset for YieldInstruction reuse + ((IEnumerator)this).Reset(); // auto-reset for YieldInstruction reuse return false; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineTrackEntryEnd.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineTrackEntryEnd.cs index dc62d4354..4c28b318b 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineTrackEntryEnd.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/YieldInstructions/WaitForSpineTrackEntryEnd.cs @@ -27,9 +27,9 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEngine; -using System.Collections; using Spine; +using System.Collections; +using UnityEngine; namespace Spine.Unity { /// @@ -70,7 +70,7 @@ namespace Spine.Unity { #region IEnumerator bool IEnumerator.MoveNext () { if (m_WasFired) { - ((IEnumerator)this).Reset(); // auto-reset for YieldInstruction reuse + ((IEnumerator)this).Reset(); // auto-reset for YieldInstruction reuse return false; } diff --git a/spine-unity/Assets/SpineTests/src/RunAnimationStateTests.cs b/spine-unity/Assets/SpineTests/src/RunAnimationStateTests.cs index 8b0b34968..83624fba2 100644 --- a/spine-unity/Assets/SpineTests/src/RunAnimationStateTests.cs +++ b/spine-unity/Assets/SpineTests/src/RunAnimationStateTests.cs @@ -1,20 +1,17 @@ -using System.Collections; +using NUnit.Framework; +using System.Collections; using System.Collections.Generic; -using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; -namespace Spine.Unity.Tests -{ - public class RunAnimationStateTests - { - [Test] - public void RunAnimationStateTestsSimplePasses () - { +namespace Spine.Unity.Tests { + public class RunAnimationStateTests { + [Test] + public void RunAnimationStateTestsSimplePasses () { AnimationStateTests.logImplementation += Log; AnimationStateTests.failImplementation += Fail; AnimationStateTests.Main("Assets/SpineTests/spine-csharp-tests/tests/assets/test.json"); - } + } public void Log (string message) { UnityEngine.Debug.Log(message); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateClipInspector.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateClipInspector.cs index 80c8eda7b..e280ed3de 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateClipInspector.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateClipInspector.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEditor; using Spine.Unity.Playables; +using UnityEditor; using UnityEngine.Timeline; namespace Spine.Unity.Editor { @@ -70,7 +70,7 @@ namespace Spine.Unity.Editor { serializedObject.ApplyModifiedProperties(); } - protected void AdjustMixDuration(SpineAnimationStateClip targetClip, ClipInfo timelineClipInfo) { + protected void AdjustMixDuration (SpineAnimationStateClip targetClip, ClipInfo timelineClipInfo) { if (timelineClipInfo == null) return; @@ -89,15 +89,14 @@ namespace Spine.Unity.Editor { } targetClip.template.mixDuration = blendInDur; EditorUtility.SetDirty(targetClip); - } - else if (wasBlendingBefore) { + } else if (wasBlendingBefore) { targetClip.template.mixDuration = timelineClipInfo.unblendedMixDuration; EditorUtility.SetDirty(targetClip); } timelineClipInfo.previousBlendInDuration = blendInDur; } - protected TimelineClip FindTimelineClip(SpineAnimationStateClip targetClip) { + protected TimelineClip FindTimelineClip (SpineAnimationStateClip targetClip) { string[] guids = AssetDatabase.FindAssets("t:TimelineAsset"); foreach (string guid in guids) { TimelineAsset timeline = (TimelineAsset)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(TimelineAsset)); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs index e5d42a464..931fc3583 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs @@ -27,12 +27,12 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEditor; -using UnityEngine; using Spine; using Spine.Unity; -using Spine.Unity.Playables; using Spine.Unity.Editor; +using Spine.Unity.Playables; +using UnityEditor; +using UnityEngine; [CustomPropertyDrawer(typeof(SpineAnimationStateBehaviour))] public class SpineAnimationStateDrawer : PropertyDrawer { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateGraphicTrackInspector.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateGraphicTrackInspector.cs index af9abd0c6..342e48cda 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateGraphicTrackInspector.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateGraphicTrackInspector.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEditor; using Spine.Unity.Playables; +using UnityEditor; using UnityEngine.Timeline; namespace Spine.Unity.Editor { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateTrackInspector.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateTrackInspector.cs index 79b915eac..e65391d11 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateTrackInspector.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateTrackInspector.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEditor; using Spine.Unity.Playables; +using UnityEditor; using UnityEngine.Timeline; namespace Spine.Unity.Editor { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipClipInspector.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipClipInspector.cs index 1deec447d..498d0c227 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipClipInspector.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipClipInspector.cs @@ -27,8 +27,8 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using UnityEditor; using Spine.Unity.Playables; +using UnityEditor; namespace Spine.Unity.Editor { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipDrawer.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipDrawer.cs index e50891676..b0fddf48b 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipDrawer.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineSkeletonFlipDrawer.cs @@ -32,8 +32,7 @@ using UnityEngine; using UnityEngine.Playables; [CustomPropertyDrawer(typeof(SpineSkeletonFlipBehaviour))] -public class SpineSkeletonFlipDrawer : PropertyDrawer -{ +public class SpineSkeletonFlipDrawer : PropertyDrawer { public override float GetPropertyHeight (SerializedProperty property, GUIContent label) { int fieldCount = 2; return fieldCount * EditorGUIUtility.singleLineHeight; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonAnimationPlayableHandle.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonAnimationPlayableHandle.cs index 166c587c3..530c554ee 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonAnimationPlayableHandle.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonAnimationPlayableHandle.cs @@ -27,14 +27,14 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; //using UnityEngine.Playables; using Spine; using Spine.Unity; using Spine.Unity.Playables; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Playables { @@ -43,7 +43,7 @@ namespace Spine.Unity.Playables { #region Inspector public SkeletonAnimation skeletonAnimation; - #if UNITY_EDITOR +#if UNITY_EDITOR void Reset () { InitializeReference(); } @@ -51,11 +51,11 @@ namespace Spine.Unity.Playables { void OnValidate () { InitializeReference(); } - #endif +#endif #endregion - public override Skeleton Skeleton { get { return skeletonAnimation.Skeleton; } } + public override Skeleton Skeleton { get { return skeletonAnimation.Skeleton; } } public override SkeletonData SkeletonData { get { return skeletonAnimation.Skeleton.Data; } } void Awake () { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonGraphicPlayableHandle.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonGraphicPlayableHandle.cs index 16a62cdf5..56e498429 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonGraphicPlayableHandle.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/PlayableHandle Component/SkeletonGraphicPlayableHandle.cs @@ -27,14 +27,14 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; //using UnityEngine.Playables; using Spine; using Spine.Unity; using Spine.Unity.Playables; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; namespace Spine.Unity.Playables { @@ -43,7 +43,7 @@ namespace Spine.Unity.Playables { #region Inspector public SkeletonGraphic skeletonGraphic; - #if UNITY_EDITOR +#if UNITY_EDITOR void Reset () { InitializeReference(); } @@ -51,11 +51,11 @@ namespace Spine.Unity.Playables { void OnValidate () { InitializeReference(); } - #endif +#endif #endregion - public override Skeleton Skeleton { get { return skeletonGraphic.Skeleton; } } + public override Skeleton Skeleton { get { return skeletonGraphic.Skeleton; } } public override SkeletonData SkeletonData { get { return skeletonGraphic.Skeleton.Data; } } void Awake () { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs index f6f7047fd..c5dd632f9 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs @@ -27,13 +27,13 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine; +using Spine.Unity; using System; +using System.Collections.Generic; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Timeline; -using Spine; -using Spine.Unity; -using System.Collections.Generic; namespace Spine.Unity.Playables { @@ -48,9 +48,9 @@ namespace Spine.Unity.Playables { public bool customDuration = false; public bool useBlendDuration = true; [SerializeField] - #pragma warning disable 414 +#pragma warning disable 414 private bool isInitialized = false; // required to read preferences values from editor side. - #pragma warning restore 414 +#pragma warning restore 414 public float mixDuration = 0.1f; public bool holdPrevious = false; public bool dontPauseWithDirector = false; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateGraphicTrack.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateGraphicTrack.cs index a2307591e..4850f5fe0 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateGraphicTrack.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateGraphicTrack.cs @@ -38,7 +38,7 @@ namespace Spine.Unity.Playables { public class SpineAnimationStateGraphicTrack : TrackAsset { public int trackIndex = 0; - public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) { + public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) { var scriptPlayable = ScriptPlayable.Create(graph, inputCount); var mixerBehaviour = scriptPlayable.GetBehaviour(); mixerBehaviour.trackIndex = this.trackIndex; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs index 33759637c..c5bdefbae 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs @@ -118,10 +118,10 @@ namespace Spine.Unity.Playables { var state = animationStateComponent.AnimationState; if (!Application.isPlaying) { - #if SPINE_EDITMODEPOSE +#if SPINE_EDITMODEPOSE PreviewEditModePose(playable, skeletonComponent, animationStateComponent, skeletonAnimation, skeletonGraphic); - #endif +#endif return; } @@ -180,8 +180,7 @@ namespace Spine.Unity.Playables { if (skeletonAnimation) { skeletonAnimation.Update(0); skeletonAnimation.LateUpdate(); - } - else if (skeletonGraphic) { + } else if (skeletonGraphic) { skeletonGraphic.Update(0); skeletonGraphic.LateUpdate(); } @@ -192,7 +191,7 @@ namespace Spine.Unity.Playables { this.lastAnyTrackPlaying = anyTrackPlaying; } - #if SPINE_EDITMODEPOSE +#if SPINE_EDITMODEPOSE AnimationState dummyAnimationState; @@ -290,7 +289,7 @@ namespace Spine.Unity.Playables { // Do nothing outside of the first clip and the last clip. } - #endif +#endif } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs index 0f8fb99e6..4165d5bba 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs @@ -38,7 +38,7 @@ namespace Spine.Unity.Playables { public class SpineAnimationStateTrack : TrackAsset { public int trackIndex = 0; - public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) { + public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) { var scriptPlayable = ScriptPlayable.Create(graph, inputCount); var mixerBehaviour = scriptPlayable.GetBehaviour(); mixerBehaviour.trackIndex = this.trackIndex; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs index 415253f5e..8bde7bdcd 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs @@ -31,13 +31,12 @@ #define PLAYABLE_DIRECTOR_HAS_STOPPED_EVENT #endif +using Spine.Unity; using System; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Timeline; -using Spine.Unity; - namespace Spine.Unity.Playables { public class SpineSkeletonFlipMixerBehaviour : PlayableBehaviour { float originalScaleX, originalScaleY; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipTrack.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipTrack.cs index 089a16362..6c46c0489 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipTrack.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipTrack.cs @@ -27,12 +27,11 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Spine.Unity; +using System.Collections.Generic; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Timeline; -using System.Collections.Generic; - -using Spine.Unity; namespace Spine.Unity.Playables { diff --git a/spine-xna/example/src/ExampleGame.cs b/spine-xna/example/src/ExampleGame.cs index 889e305e7..a43c20ce9 100644 --- a/spine-xna/example/src/ExampleGame.cs +++ b/spine-xna/example/src/ExampleGame.cs @@ -27,9 +27,6 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System; -using System.IO; -using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; @@ -37,6 +34,9 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Spine; +using System; +using System.Collections.Generic; +using System.IO; namespace Spine { public class Example : Microsoft.Xna.Framework.Game { @@ -76,8 +76,7 @@ namespace Spine { if (!useNormalmapShader) { // Two color tint effect. Note that you can also use the default BasicEffect instead. spineEffect = Content.Load("spine-xna-example-content\\SpineEffect"); - } - else { + } else { spineEffect = Content.Load("spine-xna-example-content\\SpineEffectNormalmap"); spineEffect.Parameters["Light0_Direction"].SetValue(new Vector3(-0.5265408f, 0.5735765f, -0.6275069f)); spineEffect.Parameters["Light0_Diffuse"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f)); @@ -108,8 +107,7 @@ namespace Spine { Atlas atlas; if (!useNormalmapShader) { atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice)); - } - else { + } else { atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice, loadMultipleTextureLayers: true, textureSuffixes: new string[] { "", "_normals" })); } @@ -124,8 +122,7 @@ namespace Spine { SkeletonBinary binary = new SkeletonBinary(atlas); binary.Scale = scale; skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel"); - } - else { + } else { SkeletonJson json = new SkeletonJson(atlas); json.Scale = scale; skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json"); @@ -153,19 +150,15 @@ namespace Spine { TrackEntry entry = state.AddAnimation(0, "jump", false, 0); entry.End += End; // Event handling for queued animations. state.AddAnimation(0, "run", true, 0); - } - else if (name == "raptor-pro") { + } else if (name == "raptor-pro") { state.SetAnimation(0, "walk", true); state.AddAnimation(1, "gun-grab", false, 2); - } - else if (name == "coin-pro") { + } else if (name == "coin-pro") { state.SetAnimation(0, "animation", true); - } - else if (name == "tank-pro") { + } else if (name == "tank-pro") { skeleton.X += 300; state.SetAnimation(0, "drive", true); - } - else { + } else { state.SetAnimation(0, "walk", true); } @@ -184,7 +177,7 @@ namespace Spine { // TODO: Add your update logic here #if (!WINDOWS_STOREAPP || WINDOWS_PHONE81) && !IOS if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) - this.Exit(); + this.Exit(); #endif base.Update(gameTime); } diff --git a/spine-xna/example/src/ExampleProgram.cs b/spine-xna/example/src/ExampleProgram.cs index 5f8237283..9b2995636 100644 --- a/spine-xna/example/src/ExampleProgram.cs +++ b/spine-xna/example/src/ExampleProgram.cs @@ -10,7 +10,7 @@ namespace Spine { } } } -#elif WINDOWS_STOREAPP +#elif WINDOWS_STOREAPP public static class Program { /// @@ -23,4 +23,4 @@ namespace Spine { } } #endif -} \ No newline at end of file +} diff --git a/spine-xna/src/MeshBatcher.cs b/spine-xna/src/MeshBatcher.cs index bcca36aeb..c397e6b2c 100644 --- a/spine-xna/src/MeshBatcher.cs +++ b/spine-xna/src/MeshBatcher.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework; namespace Spine { public struct VertexPositionColorTextureColor : IVertexType { diff --git a/spine-xna/src/ShapeRenderer.cs b/spine-xna/src/ShapeRenderer.cs index 08258fd2b..c9306dc31 100644 --- a/spine-xna/src/ShapeRenderer.cs +++ b/spine-xna/src/ShapeRenderer.cs @@ -47,7 +47,7 @@ namespace Spine { BasicEffect effect; public BasicEffect Effect { get { return effect; } set { effect = value; } } - public ShapeRenderer(GraphicsDevice device) { + public ShapeRenderer (GraphicsDevice device) { this.device = device; this.effect = new BasicEffect(device); effect.World = Matrix.Identity; @@ -56,27 +56,27 @@ namespace Spine { effect.VertexColorEnabled = true; } - public void SetColor(Color color) { + public void SetColor (Color color) { this.color = color; } - public void Begin() { + public void Begin () { device.RasterizerState = new RasterizerState(); device.BlendState = BlendState.AlphaBlend; } - public void Line(float x1, float y1, float x2, float y2) { + public void Line (float x1, float y1, float x2, float y2) { vertices.Add(new VertexPositionColor(new Vector3(x1, y1, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(x2, y2, 0), color)); } /** Calls {@link #circle(float, float, float, int)} by estimating the number of segments needed for a smooth circle. */ - public void Circle(float x, float y, float radius) { + public void Circle (float x, float y, float radius) { Circle(x, y, radius, Math.Max(1, (int)(6 * (float)Math.Pow(radius, 1.0f / 3.0f)))); } /** Draws a circle using {@link ShapeType#Line} or {@link ShapeType#Filled}. */ - public void Circle(float x, float y, float radius, int segments) { + public void Circle (float x, float y, float radius, int segments) { if (segments <= 0) throw new ArgumentException("segments must be > 0."); float angle = 2 * MathUtils.PI / segments; float cos = MathUtils.Cos(angle); @@ -99,7 +99,7 @@ namespace Spine { vertices.Add(new VertexPositionColor(new Vector3(x + cx, y + cy, 0), color)); } - public void Triangle(float x1, float y1, float x2, float y2, float x3, float y3) { + public void Triangle (float x1, float y1, float x2, float y2, float x3, float y3) { vertices.Add(new VertexPositionColor(new Vector3(x1, y1, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(x2, y2, 0), color)); @@ -110,13 +110,13 @@ namespace Spine { vertices.Add(new VertexPositionColor(new Vector3(x1, y1, 0), color)); } - public void X(float x, float y, float len) { + public void X (float x, float y, float len) { Line(x + len, y + len, x - len, y - len); Line(x - len, y + len, x + len, y - len); } - public void Polygon(float[] polygonVertices, int offset, int count) { - if (count< 3) throw new ArgumentException("Polygon must contain at least 3 vertices"); + public void Polygon (float[] polygonVertices, int offset, int count) { + if (count < 3) throw new ArgumentException("Polygon must contain at least 3 vertices"); offset <<= 1; @@ -143,14 +143,14 @@ namespace Spine { } } - public void Rect(float x, float y, float width, float height) { + public void Rect (float x, float y, float width, float height) { Line(x, y, x + width, y); Line(x + width, y, x + width, y + height); Line(x + width, y + height, x, y + height); Line(x, y + height, x, y); } - public void End() { + public void End () { if (vertices.Count == 0) return; var verticesArray = vertices.ToArray(); diff --git a/spine-xna/src/SkeletonDebugRenderer.cs b/spine-xna/src/SkeletonDebugRenderer.cs index 782b3ae98..1473e28a4 100644 --- a/spine-xna/src/SkeletonDebugRenderer.cs +++ b/spine-xna/src/SkeletonDebugRenderer.cs @@ -57,7 +57,7 @@ namespace Spine { public bool DrawClipping { get; set; } public bool DrawClippingDecomposed { get; set; } public bool DrawSkeletonXY { get; set; } - public void DisableAll() { + public void DisableAll () { DrawBones = false; DrawRegionAttachments = false; DrawBoundingBoxes = false; @@ -68,7 +68,7 @@ namespace Spine { DrawSkeletonXY = false; } - public void EnableAll() { + public void EnableAll () { DrawBones = true; DrawRegionAttachments = true; DrawBoundingBoxes = true; @@ -88,11 +88,11 @@ namespace Spine { EnableAll(); } - public void Begin() { + public void Begin () { renderer.Begin(); } - public void Draw(Skeleton skeleton) { + public void Draw (Skeleton skeleton) { var skeletonX = skeleton.X; var skeletonY = skeleton.Y; @@ -116,7 +116,7 @@ namespace Spine { var slot = slots.Items[i]; var attachment = slot.Attachment; if (attachment is RegionAttachment) { - var regionAttachment = (RegionAttachment) attachment; + var regionAttachment = (RegionAttachment)attachment; var vertices = this.vertices; regionAttachment.ComputeWorldVertices(slot.Bone, vertices, 0, 2); renderer.Line(vertices[0], vertices[1], vertices[2], vertices[3]); @@ -221,7 +221,7 @@ namespace Spine { } } - public void End() { + public void End () { renderer.End(); } } diff --git a/spine-xna/src/SkeletonRenderer.cs b/spine-xna/src/SkeletonRenderer.cs index 0de6b73cc..07cfd88ab 100644 --- a/spine-xna/src/SkeletonRenderer.cs +++ b/spine-xna/src/SkeletonRenderer.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework; namespace Spine { /// Draws region and mesh attachments. @@ -99,7 +99,7 @@ namespace Spine { batcher.AfterLastDrawPass(); } - public void Draw(Skeleton skeleton) { + public void Draw (Skeleton skeleton) { var drawOrder = skeleton.DrawOrder; var drawOrderItems = skeleton.DrawOrder.Items; float skeletonR = skeleton.R, skeletonG = skeleton.G, skeletonB = skeleton.B, skeletonA = skeleton.A; @@ -130,8 +130,7 @@ namespace Spine { indicesCount = 6; indices = quadTriangles; uvs = regionAttachment.UVs; - } - else if (attachment is MeshAttachment) { + } else if (attachment is MeshAttachment) { MeshAttachment mesh = (MeshAttachment)attachment; attachmentColorR = mesh.R; attachmentColorG = mesh.G; attachmentColorB = mesh.B; attachmentColorA = mesh.A; AtlasRegion region = (AtlasRegion)mesh.RendererObject; @@ -143,13 +142,11 @@ namespace Spine { indicesCount = mesh.Triangles.Length; indices = mesh.Triangles; uvs = mesh.UVs; - } - else if (attachment is ClippingAttachment) { + } else if (attachment is ClippingAttachment) { ClippingAttachment clip = (ClippingAttachment)attachment; clipper.ClipStart(slot, clip); continue; - } - else { + } else { continue; } @@ -167,8 +164,7 @@ namespace Spine { skeletonR * slot.R * attachmentColorR * a, skeletonG * slot.G * attachmentColorG * a, skeletonB * slot.B * attachmentColorB * a, a); - } - else { + } else { color = new Color( skeletonR * slot.R * attachmentColorR, skeletonG * slot.G * attachmentColorG, @@ -201,9 +197,9 @@ namespace Spine { // submit to batch MeshItem item = batcher.NextItem(verticesCount, indicesCount); if (textureObject is Texture2D) - item.texture = (Texture2D) textureObject; + item.texture = (Texture2D)textureObject; else { - item.textureLayers = (Texture2D[]) textureObject; + item.textureLayers = (Texture2D[])textureObject; item.texture = item.textureLayers[0]; } for (int ii = 0, nn = indicesCount; ii < nn; ii++) { diff --git a/spine-xna/src/Util.cs b/spine-xna/src/Util.cs index 5c6479ad8..241b6a4e1 100644 --- a/spine-xna/src/Util.cs +++ b/spine-xna/src/Util.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System; -using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; #if WINDOWS_STOREAPP using System.Threading.Tasks; diff --git a/spine-xna/src/VertexEffect.cs b/spine-xna/src/VertexEffect.cs index 16ad52b9b..480a54aba 100644 --- a/spine-xna/src/VertexEffect.cs +++ b/spine-xna/src/VertexEffect.cs @@ -34,27 +34,27 @@ using System.Text; namespace Spine { public interface IVertexEffect { - void Begin(Skeleton skeleton); - void Transform(ref VertexPositionColorTextureColor vertex); - void End(); + void Begin (Skeleton skeleton); + void Transform (ref VertexPositionColorTextureColor vertex); + void End (); } public class JitterEffect : IVertexEffect { public float JitterX { get; set; } public float JitterY { get; set; } - public JitterEffect(float jitterX, float jitterY) { + public JitterEffect (float jitterX, float jitterY) { JitterX = jitterX; JitterY = jitterY; } - public void Begin(Skeleton skeleton) { + public void Begin (Skeleton skeleton) { } - public void End() { + public void End () { } - public void Transform(ref VertexPositionColorTextureColor vertex) { + public void Transform (ref VertexPositionColorTextureColor vertex) { vertex.Position.X += MathUtils.RandomTriangle(-JitterX, JitterY); vertex.Position.Y += MathUtils.RandomTriangle(-JitterX, JitterY); } @@ -69,20 +69,20 @@ namespace Spine { public float CenterY { get; set; } public IInterpolation Interpolation { get; set; } - public SwirlEffect(float radius) { + public SwirlEffect (float radius) { Radius = radius; Interpolation = IInterpolation.Pow2; } - public void Begin(Skeleton skeleton) { + public void Begin (Skeleton skeleton) { worldX = skeleton.X + CenterX; worldY = skeleton.Y + CenterY; } - public void End() { + public void End () { } - public void Transform(ref VertexPositionColorTextureColor vertex) { + public void Transform (ref VertexPositionColorTextureColor vertex) { float x = vertex.Position.X - worldX; float y = vertex.Position.Y - worldY; float dist = (float)Math.Sqrt(x * x + y * y); diff --git a/spine-xna/src/XnaTextureLoader.cs b/spine-xna/src/XnaTextureLoader.cs index 3aa77e5c1..8580166c7 100644 --- a/spine-xna/src/XnaTextureLoader.cs +++ b/spine-xna/src/XnaTextureLoader.cs @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -using System; -using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; namespace Spine { public class XnaTextureLoader : TextureLoader { @@ -65,8 +65,7 @@ namespace Spine { if (textureLayerSuffixes == null) { page.rendererObject = texture; - } - else { + } else { Texture2D[] textureLayersArray = new Texture2D[textureLayerSuffixes.Length]; textureLayersArray[0] = texture; for (int layer = 1; layer < textureLayersArray.Length; ++layer) {