Source formatting.

So fresh and so clean!
This commit is contained in:
NathanSweet 2015-08-03 15:04:44 +02:00
parent 9478db3d2d
commit 91340709d4
28 changed files with 903 additions and 915 deletions

View File

@ -43,14 +43,14 @@ namespace Spine {
public AnimationStateData Data { get { return data; } } public AnimationStateData Data { get { return data; } }
public float TimeScale { get { return timeScale; } set { timeScale = value; } } public float TimeScale { get { return timeScale; } set { timeScale = value; } }
public delegate void StartEndDelegate(AnimationState state, int trackIndex); public delegate void StartEndDelegate (AnimationState state, int trackIndex);
public event StartEndDelegate Start; public event StartEndDelegate Start;
public event StartEndDelegate End; public event StartEndDelegate End;
public delegate void EventDelegate(AnimationState state, int trackIndex, Event e); public delegate void EventDelegate (AnimationState state, int trackIndex, Event e);
public event EventDelegate Event; public event EventDelegate Event;
public delegate void CompleteDelegate(AnimationState state, int trackIndex, int loopCount); public delegate void CompleteDelegate (AnimationState state, int trackIndex, int loopCount);
public event CompleteDelegate Complete; public event CompleteDelegate Complete;
public AnimationState (AnimationStateData data) { public AnimationState (AnimationStateData data) {

View File

@ -69,7 +69,7 @@ namespace Spine {
using (StreamReader reader = new StreamReader(stream)) using (StreamReader reader = new StreamReader(stream))
{ {
#else #else
using (StreamReader reader = new StreamReader(path)) { using (StreamReader reader = new StreamReader(path)) {
#endif #endif
try { try {
Load(reader, Path.GetDirectoryName(path), textureLoader); Load(reader, Path.GetDirectoryName(path), textureLoader);

View File

@ -97,7 +97,7 @@ namespace Spine {
return new BoundingBoxAttachment(name); return new BoundingBoxAttachment(name);
} }
public AtlasRegion FindRegion(string name) { public AtlasRegion FindRegion (string name) {
AtlasRegion region; AtlasRegion region;
for (int i = 0; i < atlasArray.Length; i++) { for (int i = 0; i < atlasArray.Length; i++) {

View File

@ -33,7 +33,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Spine { namespace Spine {
public class Bone{ public class Bone {
static public bool yDown; static public bool yDown;
internal BoneData data; internal BoneData data;

View File

@ -41,16 +41,15 @@ namespace Spine {
public class ExposedList<T> : IEnumerable<T> { public class ExposedList<T> : IEnumerable<T> {
public T[] Items; public T[] Items;
public int Count; public int Count;
private const int DefaultCapacity = 4; private const int DefaultCapacity = 4;
private static readonly T[] EmptyArray = new T[0]; private static readonly T[] EmptyArray = new T[0];
private int version; private int version;
public ExposedList() { public ExposedList () {
Items = EmptyArray; Items = EmptyArray;
} }
public ExposedList(IEnumerable<T> collection) { public ExposedList (IEnumerable<T> collection) {
CheckCollection(collection); CheckCollection(collection);
// initialize to needed size (if determinable) // initialize to needed size (if determinable)
@ -64,44 +63,44 @@ namespace Spine {
} }
} }
public ExposedList(int capacity) { public ExposedList (int capacity) {
if (capacity < 0) if (capacity < 0)
throw new ArgumentOutOfRangeException("capacity"); throw new ArgumentOutOfRangeException("capacity");
Items = new T[capacity]; Items = new T[capacity];
} }
internal ExposedList(T[] data, int size) { internal ExposedList (T[] data, int size) {
Items = data; Items = data;
Count = size; Count = size;
} }
public void Add(T item) { public void Add (T item) {
// If we check to see if we need to grow before trying to grow // If we check to see if we need to grow before trying to grow
// we can speed things up by 25% // we can speed things up by 25%
if (Count == Items.Length) if (Count == Items.Length)
GrowIfNeeded(1); GrowIfNeeded(1);
Items[Count ++] = item; Items[Count++] = item;
version++; version++;
} }
public void GrowIfNeeded(int newCount) { public void GrowIfNeeded (int newCount) {
int minimumSize = Count + newCount; int minimumSize = Count + newCount;
if (minimumSize > Items.Length) if (minimumSize > Items.Length)
Capacity = Math.Max(Math.Max(Capacity * 2, DefaultCapacity), minimumSize); Capacity = Math.Max(Math.Max(Capacity * 2, DefaultCapacity), minimumSize);
} }
private void CheckRange(int idx, int count) { private void CheckRange (int idx, int count) {
if (idx < 0) if (idx < 0)
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
if (count < 0) if (count < 0)
throw new ArgumentOutOfRangeException("count"); throw new ArgumentOutOfRangeException("count");
if ((uint) idx + (uint) count > (uint) Count) if ((uint)idx + (uint)count > (uint)Count)
throw new ArgumentException("index and count exceed length of list"); throw new ArgumentException("index and count exceed length of list");
} }
private void AddCollection(ICollection<T> collection) { private void AddCollection (ICollection<T> collection) {
int collectionCount = collection.Count; int collectionCount = collection.Count;
if (collectionCount == 0) if (collectionCount == 0)
return; return;
@ -111,13 +110,13 @@ namespace Spine {
Count += collectionCount; Count += collectionCount;
} }
private void AddEnumerable(IEnumerable<T> enumerable) { private void AddEnumerable (IEnumerable<T> enumerable) {
foreach (T t in enumerable) { foreach (T t in enumerable) {
Add(t); Add(t);
} }
} }
public void AddRange(IEnumerable<T> collection) { public void AddRange (IEnumerable<T> collection) {
CheckCollection(collection); CheckCollection(collection);
ICollection<T> c = collection as ICollection<T>; ICollection<T> c = collection as ICollection<T>;
@ -128,20 +127,20 @@ namespace Spine {
version++; version++;
} }
public int BinarySearch(T item) { public int BinarySearch (T item) {
return Array.BinarySearch<T>(Items, 0, Count, item); return Array.BinarySearch<T>(Items, 0, Count, item);
} }
public int BinarySearch(T item, IComparer<T> comparer) { public int BinarySearch (T item, IComparer<T> comparer) {
return Array.BinarySearch<T>(Items, 0, Count, item, comparer); return Array.BinarySearch<T>(Items, 0, Count, item, comparer);
} }
public int BinarySearch(int index, int count, T item, IComparer<T> comparer) { public int BinarySearch (int index, int count, T item, IComparer<T> comparer) {
CheckRange(index, count); CheckRange(index, count);
return Array.BinarySearch<T>(Items, index, count, item, comparer); return Array.BinarySearch<T>(Items, index, count, item, comparer);
} }
public void Clear(bool clearArray = true) { public void Clear (bool clearArray = true) {
if (clearArray) if (clearArray)
Array.Clear(Items, 0, Items.Length); Array.Clear(Items, 0, Items.Length);
@ -149,11 +148,11 @@ namespace Spine {
version++; version++;
} }
public bool Contains(T item) { public bool Contains (T item) {
return Array.IndexOf<T>(Items, item, 0, Count) != -1; return Array.IndexOf<T>(Items, item, 0, Count) != -1;
} }
public ExposedList<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter) { public ExposedList<TOutput> ConvertAll<TOutput> (Converter<T, TOutput> converter) {
if (converter == null) if (converter == null)
throw new ArgumentNullException("converter"); throw new ArgumentNullException("converter");
ExposedList<TOutput> u = new ExposedList<TOutput>(Count); ExposedList<TOutput> u = new ExposedList<TOutput>(Count);
@ -164,41 +163,41 @@ namespace Spine {
return u; return u;
} }
public void CopyTo(T[] array) { public void CopyTo (T[] array) {
Array.Copy(Items, 0, array, 0, Count); Array.Copy(Items, 0, array, 0, Count);
} }
public void CopyTo(T[] array, int arrayIndex) { public void CopyTo (T[] array, int arrayIndex) {
Array.Copy(Items, 0, array, arrayIndex, Count); Array.Copy(Items, 0, array, arrayIndex, Count);
} }
public void CopyTo(int index, T[] array, int arrayIndex, int count) { public void CopyTo (int index, T[] array, int arrayIndex, int count) {
CheckRange(index, count); CheckRange(index, count);
Array.Copy(Items, index, array, arrayIndex, count); Array.Copy(Items, index, array, arrayIndex, count);
} }
public bool Exists(Predicate<T> match) { public bool Exists (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
return GetIndex(0, Count, match) != -1; return GetIndex(0, Count, match) != -1;
} }
public T Find(Predicate<T> match) { public T Find (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
int i = GetIndex(0, Count, match); int i = GetIndex(0, Count, match);
return (i != -1) ? Items[i] : default (T); return (i != -1) ? Items[i] : default(T);
} }
private static void CheckMatch(Predicate<T> match) { private static void CheckMatch (Predicate<T> match) {
if (match == null) if (match == null)
throw new ArgumentNullException("match"); throw new ArgumentNullException("match");
} }
public ExposedList<T> FindAll(Predicate<T> match) { public ExposedList<T> FindAll (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
return FindAllList(match); return FindAllList(match);
} }
private ExposedList<T> FindAllList(Predicate<T> match) { private ExposedList<T> FindAllList (Predicate<T> match) {
ExposedList<T> results = new ExposedList<T>(); ExposedList<T> results = new ExposedList<T>();
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
if (match(Items[i])) if (match(Items[i]))
@ -207,105 +206,105 @@ namespace Spine {
return results; return results;
} }
public int FindIndex(Predicate<T> match) { public int FindIndex (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
return GetIndex(0, Count, match); return GetIndex(0, Count, match);
} }
public int FindIndex(int startIndex, Predicate<T> match) { public int FindIndex (int startIndex, Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
CheckIndex(startIndex); CheckIndex(startIndex);
return GetIndex(startIndex, Count - startIndex, match); return GetIndex(startIndex, Count - startIndex, match);
} }
public int FindIndex(int startIndex, int count, Predicate<T> match) { public int FindIndex (int startIndex, int count, Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
CheckRange(startIndex, count); CheckRange(startIndex, count);
return GetIndex(startIndex, count, match); return GetIndex(startIndex, count, match);
} }
private int GetIndex(int startIndex, int count, Predicate<T> match) { private int GetIndex (int startIndex, int count, Predicate<T> match) {
int end = startIndex + count; int end = startIndex + count;
for (int i = startIndex; i < end; i ++) for (int i = startIndex; i < end; i++)
if (match(Items[i])) if (match(Items[i]))
return i; return i;
return -1; return -1;
} }
public T FindLast(Predicate<T> match) { public T FindLast (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
int i = GetLastIndex(0, Count, match); int i = GetLastIndex(0, Count, match);
return i == -1 ? default (T) : Items[i]; return i == -1 ? default(T) : Items[i];
} }
public int FindLastIndex(Predicate<T> match) { public int FindLastIndex (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
return GetLastIndex(0, Count, match); return GetLastIndex(0, Count, match);
} }
public int FindLastIndex(int startIndex, Predicate<T> match) { public int FindLastIndex (int startIndex, Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
CheckIndex(startIndex); CheckIndex(startIndex);
return GetLastIndex(0, startIndex + 1, match); return GetLastIndex(0, startIndex + 1, match);
} }
public int FindLastIndex(int startIndex, int count, Predicate<T> match) { public int FindLastIndex (int startIndex, int count, Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
int start = startIndex - count + 1; int start = startIndex - count + 1;
CheckRange(start, count); CheckRange(start, count);
return GetLastIndex(start, count, match); return GetLastIndex(start, count, match);
} }
private int GetLastIndex(int startIndex, int count, Predicate<T> match) { private int GetLastIndex (int startIndex, int count, Predicate<T> match) {
// unlike FindLastIndex, takes regular params for search range // 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])) if (match(Items[--i]))
return i; return i;
return -1; return -1;
} }
public void ForEach(Action<T> action) { public void ForEach (Action<T> action) {
if (action == null) if (action == null)
throw new ArgumentNullException("action"); throw new ArgumentNullException("action");
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
action(Items[i]); action(Items[i]);
} }
public Enumerator GetEnumerator() { public Enumerator GetEnumerator () {
return new Enumerator(this); return new Enumerator(this);
} }
public ExposedList<T> GetRange(int index, int count) { public ExposedList<T> GetRange (int index, int count) {
CheckRange(index, count); CheckRange(index, count);
T[] tmpArray = new T[count]; T[] tmpArray = new T[count];
Array.Copy(Items, index, tmpArray, 0, count); Array.Copy(Items, index, tmpArray, 0, count);
return new ExposedList<T>(tmpArray, count); return new ExposedList<T>(tmpArray, count);
} }
public int IndexOf(T item) { public int IndexOf (T item) {
return Array.IndexOf<T>(Items, item, 0, Count); return Array.IndexOf<T>(Items, item, 0, Count);
} }
public int IndexOf(T item, int index) { public int IndexOf (T item, int index) {
CheckIndex(index); CheckIndex(index);
return Array.IndexOf<T>(Items, item, index, Count - index); return Array.IndexOf<T>(Items, item, index, Count - index);
} }
public int IndexOf(T item, int index, int count) { public int IndexOf (T item, int index, int count) {
if (index < 0) if (index < 0)
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
if (count < 0) if (count < 0)
throw new ArgumentOutOfRangeException("count"); throw new ArgumentOutOfRangeException("count");
if ((uint) index + (uint) count > (uint) Count) if ((uint)index + (uint)count > (uint)Count)
throw new ArgumentOutOfRangeException("index and count exceed length of list"); throw new ArgumentOutOfRangeException("index and count exceed length of list");
return Array.IndexOf<T>(Items, item, index, count); return Array.IndexOf<T>(Items, item, index, count);
} }
private void Shift(int start, int delta) { private void Shift (int start, int delta) {
if (delta < 0) if (delta < 0)
start -= delta; start -= delta;
@ -318,12 +317,12 @@ namespace Spine {
Array.Clear(Items, Count, -delta); Array.Clear(Items, Count, -delta);
} }
private void CheckIndex(int index) { private void CheckIndex (int index) {
if (index < 0 || (uint) index > (uint) Count) if (index < 0 || (uint)index > (uint)Count)
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
public void Insert(int index, T item) { public void Insert (int index, T item) {
CheckIndex(index); CheckIndex(index);
if (Count == Items.Length) if (Count == Items.Length)
GrowIfNeeded(1); GrowIfNeeded(1);
@ -332,12 +331,12 @@ namespace Spine {
version++; version++;
} }
private void CheckCollection(IEnumerable<T> collection) { private void CheckCollection (IEnumerable<T> collection) {
if (collection == null) if (collection == null)
throw new ArgumentNullException("collection"); throw new ArgumentNullException("collection");
} }
public void InsertRange(int index, IEnumerable<T> collection) { public void InsertRange (int index, IEnumerable<T> collection) {
CheckCollection(collection); CheckCollection(collection);
CheckIndex(index); CheckIndex(index);
if (collection == this) { if (collection == this) {
@ -356,7 +355,7 @@ namespace Spine {
version++; version++;
} }
private void InsertCollection(int index, ICollection<T> collection) { private void InsertCollection (int index, ICollection<T> collection) {
int collectionCount = collection.Count; int collectionCount = collection.Count;
GrowIfNeeded(collectionCount); GrowIfNeeded(collectionCount);
@ -364,21 +363,21 @@ namespace Spine {
collection.CopyTo(Items, index); collection.CopyTo(Items, index);
} }
private void InsertEnumeration(int index, IEnumerable<T> enumerable) { private void InsertEnumeration (int index, IEnumerable<T> enumerable) {
foreach (T t in enumerable) foreach (T t in enumerable)
Insert(index++, t); Insert(index++, t);
} }
public int LastIndexOf(T item) { public int LastIndexOf (T item) {
return Array.LastIndexOf<T>(Items, item, Count - 1, Count); return Array.LastIndexOf<T>(Items, item, Count - 1, Count);
} }
public int LastIndexOf(T item, int index) { public int LastIndexOf (T item, int index) {
CheckIndex(index); CheckIndex(index);
return Array.LastIndexOf<T>(Items, item, index, index + 1); return Array.LastIndexOf<T>(Items, item, index, index + 1);
} }
public int LastIndexOf(T item, int index, int count) { public int LastIndexOf (T item, int index, int count) {
if (index < 0) if (index < 0)
throw new ArgumentOutOfRangeException("index", index, "index is negative"); throw new ArgumentOutOfRangeException("index", index, "index is negative");
@ -391,7 +390,7 @@ namespace Spine {
return Array.LastIndexOf<T>(Items, item, index, count); return Array.LastIndexOf<T>(Items, item, index, count);
} }
public bool Remove(T item) { public bool Remove (T item) {
int loc = IndexOf(item); int loc = IndexOf(item);
if (loc != -1) if (loc != -1)
RemoveAt(loc); RemoveAt(loc);
@ -399,7 +398,7 @@ namespace Spine {
return loc != -1; return loc != -1;
} }
public int RemoveAll(Predicate<T> match) { public int RemoveAll (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
int i = 0; int i = 0;
int j = 0; int j = 0;
@ -426,15 +425,15 @@ namespace Spine {
return (j - i); return (j - i);
} }
public void RemoveAt(int index) { public void RemoveAt (int index) {
if (index < 0 || (uint) index >= (uint) Count) if (index < 0 || (uint)index >= (uint)Count)
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
Shift(index, -1); Shift(index, -1);
Array.Clear(Items, Count, 1); Array.Clear(Items, Count, 1);
version++; version++;
} }
public void RemoveRange(int index, int count) { public void RemoveRange (int index, int count) {
CheckRange(index, count); CheckRange(index, count);
if (count > 0) { if (count > 0) {
Shift(index, -count); Shift(index, -count);
@ -443,50 +442,50 @@ namespace Spine {
} }
} }
public void Reverse() { public void Reverse () {
Array.Reverse(Items, 0, Count); Array.Reverse(Items, 0, Count);
version++; version++;
} }
public void Reverse(int index, int count) { public void Reverse (int index, int count) {
CheckRange(index, count); CheckRange(index, count);
Array.Reverse(Items, index, count); Array.Reverse(Items, index, count);
version++; version++;
} }
public void Sort() { public void Sort () {
Array.Sort<T>(Items, 0, Count, Comparer<T>.Default); Array.Sort<T>(Items, 0, Count, Comparer<T>.Default);
version++; version++;
} }
public void Sort(IComparer<T> comparer) { public void Sort (IComparer<T> comparer) {
Array.Sort<T>(Items, 0, Count, comparer); Array.Sort<T>(Items, 0, Count, comparer);
version++; version++;
} }
public void Sort(Comparison<T> comparison) { public void Sort (Comparison<T> comparison) {
Array.Sort<T>(Items, comparison); Array.Sort<T>(Items, comparison);
version++; version++;
} }
public void Sort(int index, int count, IComparer<T> comparer) { public void Sort (int index, int count, IComparer<T> comparer) {
CheckRange(index, count); CheckRange(index, count);
Array.Sort<T>(Items, index, count, comparer); Array.Sort<T>(Items, index, count, comparer);
version++; version++;
} }
public T[] ToArray() { public T[] ToArray () {
T[] t = new T[Count]; T[] t = new T[Count];
Array.Copy(Items, t, Count); Array.Copy(Items, t, Count);
return t; return t;
} }
public void TrimExcess() { public void TrimExcess () {
Capacity = Count; Capacity = Count;
} }
public bool TrueForAll(Predicate<T> match) { public bool TrueForAll (Predicate<T> match) {
CheckMatch(match); CheckMatch(match);
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
@ -501,7 +500,7 @@ namespace Spine {
return Items.Length; return Items.Length;
} }
set { set {
if ((uint) value < (uint) Count) if ((uint)value < (uint)Count)
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
Array.Resize(ref Items, value); Array.Resize(ref Items, value);
@ -510,11 +509,11 @@ namespace Spine {
#region Interface implementations. #region Interface implementations.
IEnumerator<T> IEnumerable<T>.GetEnumerator() { IEnumerator<T> IEnumerable<T>.GetEnumerator () {
return GetEnumerator(); return GetEnumerator();
} }
IEnumerator IEnumerable.GetEnumerator() { IEnumerator IEnumerable.GetEnumerator () {
return GetEnumerator(); return GetEnumerator();
} }
@ -525,28 +524,27 @@ namespace Spine {
private ExposedList<T> l; private ExposedList<T> l;
private int next; private int next;
private int ver; private int ver;
private T current; private T current;
internal Enumerator(ExposedList<T> l) internal Enumerator (ExposedList<T> l)
: this() { : this() {
this.l = l; this.l = l;
ver = l.version; ver = l.version;
} }
public void Dispose() { public void Dispose () {
l = null; l = null;
} }
private void VerifyState() { private void VerifyState () {
if (l == null) if (l == null)
throw new ObjectDisposedException(GetType().FullName); throw new ObjectDisposedException(GetType().FullName);
if (ver != l.version) if (ver != l.version)
throw new InvalidOperationException( throw new InvalidOperationException(
"Collection was modified; enumeration operation may not execute."); "Collection was modified; enumeration operation may not execute.");
} }
public bool MoveNext() { public bool MoveNext () {
VerifyState(); VerifyState();
if (next < 0) if (next < 0)
@ -567,7 +565,7 @@ namespace Spine {
} }
} }
void IEnumerator.Reset() { void IEnumerator.Reset () {
VerifyState(); VerifyState();
next = 0; next = 0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -133,7 +133,7 @@ namespace Spine {
current = current.parent; current = current.parent;
} while (current != null); } while (current != null);
nonIkBones.Add(bone); nonIkBones.Add(bone);
outer: {} outer: { }
} }
} }

View File

@ -217,95 +217,95 @@ namespace Spine {
switch ((AttachmentType)input.ReadByte()) { switch ((AttachmentType)input.ReadByte()) {
case AttachmentType.region: { case AttachmentType.region: {
String path = ReadString(input); String path = ReadString(input);
if (path == null) path = name; if (path == null) path = name;
RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path); RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path);
if (region == null) return null; if (region == null) return null;
region.Path = path; region.Path = path;
region.x = ReadFloat(input) * scale; region.x = ReadFloat(input) * scale;
region.y = ReadFloat(input) * scale; region.y = ReadFloat(input) * scale;
region.scaleX = ReadFloat(input); region.scaleX = ReadFloat(input);
region.scaleY = ReadFloat(input); region.scaleY = ReadFloat(input);
region.rotation = ReadFloat(input); region.rotation = ReadFloat(input);
region.width = ReadFloat(input) * scale; region.width = ReadFloat(input) * scale;
region.height = ReadFloat(input) * scale; region.height = ReadFloat(input) * scale;
int color = ReadInt(input); int color = ReadInt(input);
region.r = ((color & 0xff000000) >> 24) / 255f; region.r = ((color & 0xff000000) >> 24) / 255f;
region.g = ((color & 0x00ff0000) >> 16) / 255f; region.g = ((color & 0x00ff0000) >> 16) / 255f;
region.b = ((color & 0x0000ff00) >> 8) / 255f; region.b = ((color & 0x0000ff00) >> 8) / 255f;
region.a = ((color & 0x000000ff)) / 255f; region.a = ((color & 0x000000ff)) / 255f;
region.UpdateOffset(); region.UpdateOffset();
return region; return region;
} }
case AttachmentType.boundingbox: { case AttachmentType.boundingbox: {
BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name); BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name);
if (box == null) return null; if (box == null) return null;
box.vertices = ReadFloatArray(input, scale); box.vertices = ReadFloatArray(input, scale);
return box; return box;
} }
case AttachmentType.mesh: { case AttachmentType.mesh: {
String path = ReadString(input); String path = ReadString(input);
if (path == null) path = name; if (path == null) path = name;
MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
if (mesh == null) return null; if (mesh == null) return null;
mesh.Path = path; mesh.Path = path;
mesh.regionUVs = ReadFloatArray(input, 1); mesh.regionUVs = ReadFloatArray(input, 1);
mesh.triangles = ReadShortArray(input); mesh.triangles = ReadShortArray(input);
mesh.vertices = ReadFloatArray(input, scale); mesh.vertices = ReadFloatArray(input, scale);
mesh.UpdateUVs(); mesh.UpdateUVs();
int color = ReadInt(input); int color = ReadInt(input);
mesh.r = ((color & 0xff000000) >> 24) / 255f; mesh.r = ((color & 0xff000000) >> 24) / 255f;
mesh.g = ((color & 0x00ff0000) >> 16) / 255f; mesh.g = ((color & 0x00ff0000) >> 16) / 255f;
mesh.b = ((color & 0x0000ff00) >> 8) / 255f; mesh.b = ((color & 0x0000ff00) >> 8) / 255f;
mesh.a = ((color & 0x000000ff)) / 255f; mesh.a = ((color & 0x000000ff)) / 255f;
mesh.HullLength = ReadInt(input, true) * 2; mesh.HullLength = ReadInt(input, true) * 2;
if (nonessential) { if (nonessential) {
mesh.Edges = ReadIntArray(input); mesh.Edges = ReadIntArray(input);
mesh.Width = ReadFloat(input) * scale; mesh.Width = ReadFloat(input) * scale;
mesh.Height = ReadFloat(input) * scale; mesh.Height = ReadFloat(input) * scale;
}
return mesh;
}
case AttachmentType.skinnedmesh: {
String path = ReadString(input);
if (path == null) path = name;
SkinnedMeshAttachment mesh = attachmentLoader.NewSkinnedMeshAttachment(skin, name, path);
if (mesh == null) return null;
mesh.Path = path;
float[] uvs = ReadFloatArray(input, 1);
int[] triangles = ReadShortArray(input);
int vertexCount = ReadInt(input, true);
var weights = new List<float>(uvs.Length * 3 * 3);
var bones = new List<int>(uvs.Length * 3);
for (int i = 0; i < vertexCount; i++) {
int boneCount = (int)ReadFloat(input);
bones.Add(boneCount);
for (int nn = i + boneCount * 4; i < nn; i += 4) {
bones.Add((int)ReadFloat(input));
weights.Add(ReadFloat(input) * scale);
weights.Add(ReadFloat(input) * scale);
weights.Add(ReadFloat(input));
} }
return mesh;
} }
mesh.bones = bones.ToArray(); case AttachmentType.skinnedmesh: {
mesh.weights = weights.ToArray(); String path = ReadString(input);
mesh.triangles = triangles; if (path == null) path = name;
mesh.regionUVs = uvs; SkinnedMeshAttachment mesh = attachmentLoader.NewSkinnedMeshAttachment(skin, name, path);
mesh.UpdateUVs(); if (mesh == null) return null;
int color = ReadInt(input); mesh.Path = path;
mesh.r = ((color & 0xff000000) >> 24) / 255f; float[] uvs = ReadFloatArray(input, 1);
mesh.g = ((color & 0x00ff0000) >> 16) / 255f; int[] triangles = ReadShortArray(input);
mesh.b = ((color & 0x0000ff00) >> 8) / 255f;
mesh.a = ((color & 0x000000ff)) / 255f; int vertexCount = ReadInt(input, true);
mesh.HullLength = ReadInt(input, true) * 2; var weights = new List<float>(uvs.Length * 3 * 3);
if (nonessential) { var bones = new List<int>(uvs.Length * 3);
mesh.Edges = ReadIntArray(input); for (int i = 0; i < vertexCount; i++) {
mesh.Width = ReadFloat(input) * scale; int boneCount = (int)ReadFloat(input);
mesh.Height = ReadFloat(input) * scale; bones.Add(boneCount);
for (int nn = i + boneCount * 4; i < nn; i += 4) {
bones.Add((int)ReadFloat(input));
weights.Add(ReadFloat(input) * scale);
weights.Add(ReadFloat(input) * scale);
weights.Add(ReadFloat(input));
}
}
mesh.bones = bones.ToArray();
mesh.weights = weights.ToArray();
mesh.triangles = triangles;
mesh.regionUVs = uvs;
mesh.UpdateUVs();
int color = ReadInt(input);
mesh.r = ((color & 0xff000000) >> 24) / 255f;
mesh.g = ((color & 0x00ff0000) >> 16) / 255f;
mesh.b = ((color & 0x0000ff00) >> 8) / 255f;
mesh.a = ((color & 0x000000ff)) / 255f;
mesh.HullLength = ReadInt(input, true) * 2;
if (nonessential) {
mesh.Edges = ReadIntArray(input);
mesh.Width = ReadFloat(input) * scale;
mesh.Height = ReadFloat(input) * scale;
}
return mesh;
} }
return mesh;
}
} }
return null; return null;
} }
@ -352,31 +352,31 @@ namespace Spine {
int frameCount = ReadInt(input, true); int frameCount = ReadInt(input, true);
switch (timelineType) { switch (timelineType) {
case TIMELINE_COLOR: { case TIMELINE_COLOR: {
ColorTimeline timeline = new ColorTimeline(frameCount); ColorTimeline timeline = new ColorTimeline(frameCount);
timeline.slotIndex = slotIndex; timeline.slotIndex = slotIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
float time = ReadFloat(input); float time = ReadFloat(input);
int color = ReadInt(input); int color = ReadInt(input);
float r = ((color & 0xff000000) >> 24) / 255f; float r = ((color & 0xff000000) >> 24) / 255f;
float g = ((color & 0x00ff0000) >> 16) / 255f; float g = ((color & 0x00ff0000) >> 16) / 255f;
float b = ((color & 0x0000ff00) >> 8) / 255f; float b = ((color & 0x0000ff00) >> 8) / 255f;
float a = ((color & 0x000000ff)) / 255f; float a = ((color & 0x000000ff)) / 255f;
timeline.SetFrame(frameIndex, time, r, g, b, a); timeline.SetFrame(frameIndex, time, r, g, b, a);
if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline); if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline);
}
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 5 - 5]);
break;
} }
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 5 - 5]);
break;
}
case TIMELINE_ATTACHMENT: { case TIMELINE_ATTACHMENT: {
AttachmentTimeline timeline = new AttachmentTimeline(frameCount); AttachmentTimeline timeline = new AttachmentTimeline(frameCount);
timeline.slotIndex = slotIndex; timeline.slotIndex = slotIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.SetFrame(frameIndex, ReadFloat(input), ReadString(input)); timeline.SetFrame(frameIndex, ReadFloat(input), ReadString(input));
timelines.Add(timeline); timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount - 1]); duration = Math.Max(duration, timeline.frames[frameCount - 1]);
break; break;
} }
} }
} }
} }
@ -389,47 +389,47 @@ namespace Spine {
int frameCount = ReadInt(input, true); int frameCount = ReadInt(input, true);
switch (timelineType) { switch (timelineType) {
case TIMELINE_ROTATE: { case TIMELINE_ROTATE: {
RotateTimeline timeline = new RotateTimeline(frameCount); RotateTimeline timeline = new RotateTimeline(frameCount);
timeline.boneIndex = boneIndex; timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input)); timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input));
if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline); if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline);
}
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 2 - 2]);
break;
} }
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 2 - 2]);
break;
}
case TIMELINE_TRANSLATE: case TIMELINE_TRANSLATE:
case TIMELINE_SCALE: { case TIMELINE_SCALE: {
TranslateTimeline timeline; TranslateTimeline timeline;
float timelineScale = 1; float timelineScale = 1;
if (timelineType == TIMELINE_SCALE) if (timelineType == TIMELINE_SCALE)
timeline = new ScaleTimeline(frameCount); timeline = new ScaleTimeline(frameCount);
else { else {
timeline = new TranslateTimeline(frameCount); timeline = new TranslateTimeline(frameCount);
timelineScale = scale; timelineScale = scale;
}
timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input) * timelineScale, ReadFloat(input)
* timelineScale);
if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline);
}
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 3 - 3]);
break;
} }
timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input) * timelineScale, ReadFloat(input)
* timelineScale);
if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline);
}
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 3 - 3]);
break;
}
case TIMELINE_FLIPX: case TIMELINE_FLIPX:
case TIMELINE_FLIPY: { case TIMELINE_FLIPY: {
FlipXTimeline timeline = timelineType == TIMELINE_FLIPX ? new FlipXTimeline(frameCount) : new FlipYTimeline( FlipXTimeline timeline = timelineType == TIMELINE_FLIPX ? new FlipXTimeline(frameCount) : new FlipYTimeline(
frameCount); frameCount);
timeline.boneIndex = boneIndex; timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.SetFrame(frameIndex, ReadFloat(input), ReadBoolean(input)); timeline.SetFrame(frameIndex, ReadFloat(input), ReadBoolean(input));
timelines.Add(timeline); timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 2 - 2]); duration = Math.Max(duration, timeline.frames[frameCount * 2 - 2]);
break; break;
} }
} }
} }
} }

View File

@ -91,7 +91,7 @@ namespace Spine {
internal static readonly AttachmentKeyTupleComparer Instance = new AttachmentKeyTupleComparer(); internal static readonly AttachmentKeyTupleComparer Instance = new AttachmentKeyTupleComparer();
bool IEqualityComparer<AttachmentKeyTuple>.Equals (AttachmentKeyTuple o1, AttachmentKeyTuple o2) { bool IEqualityComparer<AttachmentKeyTuple>.Equals (AttachmentKeyTuple o1, AttachmentKeyTuple o2) {
return o1.SlotIndex == o2.SlotIndex && o1.NameHashCode == o2.NameHashCode && o1.Name == o2.Name; return o1.SlotIndex == o2.SlotIndex && o1.NameHashCode == o2.NameHashCode && o1.Name == o2.Name;
} }
int IEqualityComparer<AttachmentKeyTuple>.GetHashCode (AttachmentKeyTuple o) { int IEqualityComparer<AttachmentKeyTuple>.GetHashCode (AttachmentKeyTuple o) {
@ -99,16 +99,16 @@ namespace Spine {
} }
} }
private class AttachmentKeyTuple { private class AttachmentKeyTuple {
public readonly int SlotIndex; public readonly int SlotIndex;
public readonly string Name; public readonly string Name;
public readonly int NameHashCode; public readonly int NameHashCode;
public AttachmentKeyTuple(int slotIndex, string name) { public AttachmentKeyTuple (int slotIndex, string name) {
SlotIndex = slotIndex; SlotIndex = slotIndex;
Name = name; Name = name;
NameHashCode = Name.GetHashCode(); NameHashCode = Name.GetHashCode();
} }
} }
} }
} }

View File

@ -84,7 +84,7 @@ public class AtlasAsset : ScriptableObject {
return sprite; return sprite;
} }
public Mesh GenerateMesh(string name, Mesh mesh, out Material material, float scale = 0.01f){ public Mesh GenerateMesh (string name, Mesh mesh, out Material material, float scale = 0.01f) {
AtlasRegion region = atlas.FindRegion(name); AtlasRegion region = atlas.FindRegion(name);
material = null; material = null;
if (region != null) { if (region != null) {
@ -95,7 +95,7 @@ public class AtlasAsset : ScriptableObject {
Vector3[] verts = new Vector3[4]; Vector3[] verts = new Vector3[4];
Vector2[] uvs = new Vector2[4]; Vector2[] uvs = new Vector2[4];
Color[] colors = new Color[4]{Color.white, Color.white, Color.white, Color.white}; Color[] colors = new Color[4] { Color.white, Color.white, Color.white, Color.white };
int[] triangles = new int[6] { 0, 1, 2, 2, 3, 0 }; int[] triangles = new int[6] { 0, 1, 2, 2, 3, 0 };
float left, right, top, bottom; float left, right, top, bottom;

View File

@ -50,12 +50,12 @@ public class AtlasRegionAttacher : MonoBehaviour {
Atlas atlas; Atlas atlas;
void Awake() { void Awake () {
GetComponent<SkeletonRenderer>().OnReset += Apply; GetComponent<SkeletonRenderer>().OnReset += Apply;
} }
void Apply(SkeletonRenderer skeletonRenderer) { void Apply (SkeletonRenderer skeletonRenderer) {
atlas = atlasAsset.GetAtlas(); atlas = atlasAsset.GetAtlas();
AtlasAttachmentLoader loader = new AtlasAttachmentLoader(atlas); AtlasAttachmentLoader loader = new AtlasAttachmentLoader(atlas);

View File

@ -51,7 +51,7 @@ public class CustomSkin : MonoBehaviour {
public Skin customSkin; public Skin customSkin;
SkeletonRenderer skeletonRenderer; SkeletonRenderer skeletonRenderer;
void Start() { void Start () {
skeletonRenderer = GetComponent<SkeletonRenderer>(); skeletonRenderer = GetComponent<SkeletonRenderer>();
Skeleton skeleton = skeletonRenderer.skeleton; Skeleton skeleton = skeletonRenderer.skeleton;

View File

@ -83,7 +83,7 @@ public class SkeletonGhostRenderer : MonoBehaviour {
c = colors[i]; c = colors[i];
black.a = c.a; black.a = c.a;
if (c.r > 0 || c.g > 0 || c.b > 0) if (c.r > 0 || c.g > 0 || c.b > 0)
breakout = false; breakout = false;
colors[i] = Color32.Lerp(c, black, Time.deltaTime * fadeSpeed); colors[i] = Color32.Lerp(c, black, Time.deltaTime * fadeSpeed);
} }

View File

@ -67,7 +67,7 @@ public class SkeletonRagdoll : MonoBehaviour {
private Rigidbody rootRigidbody; private Rigidbody rootRigidbody;
private ISkeletonAnimation skeletonAnim; private ISkeletonAnimation skeletonAnim;
private Skeleton skeleton; private Skeleton skeleton;
private Dictionary<Bone, Transform> boneTable = new Dictionary<Bone,Transform>(); private Dictionary<Bone, Transform> boneTable = new Dictionary<Bone, Transform>();
private Bone startingBone; private Bone startingBone;
private Transform ragdollRoot; private Transform ragdollRoot;
private Vector3 rootOffset; private Vector3 rootOffset;
@ -121,7 +121,7 @@ public class SkeletonRagdoll : MonoBehaviour {
Rigidbody[] arr = new Rigidbody[boneTable.Count]; Rigidbody[] arr = new Rigidbody[boneTable.Count];
int i = 0; int i = 0;
foreach(Transform t in boneTable.Values){ foreach (Transform t in boneTable.Values) {
arr[i] = t.GetComponent<Rigidbody>(); arr[i] = t.GetComponent<Rigidbody>();
i++; i++;
} }

View File

@ -191,7 +191,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
lastTime = Time.time; lastTime = Time.time;
} }
private int GetAnimationClipNameHashCode(AnimationClip clip) { private int GetAnimationClipNameHashCode (AnimationClip clip) {
int clipNameHashCode; int clipNameHashCode;
if (!clipNameHashCodeTable.TryGetValue(clip, out clipNameHashCode)) { if (!clipNameHashCodeTable.TryGetValue(clip, out clipNameHashCode)) {
clipNameHashCode = clip.name.GetHashCode(); clipNameHashCode = clip.name.GetHashCode();

View File

@ -50,12 +50,12 @@ public class SkeletonDataAsset : ScriptableObject {
private SkeletonData skeletonData; private SkeletonData skeletonData;
private AnimationStateData stateData; private AnimationStateData stateData;
public void Reset() { public void Reset () {
skeletonData = null; skeletonData = null;
stateData = null; stateData = null;
} }
public SkeletonData GetSkeletonData(bool quiet) { public SkeletonData GetSkeletonData (bool quiet) {
if (atlasAssets == null) { if (atlasAssets == null) {
atlasAssets = new AtlasAsset[0]; atlasAssets = new AtlasAsset[0];
if (!quiet) if (!quiet)
@ -161,7 +161,7 @@ public class SkeletonDataAsset : ScriptableObject {
} }
} }
public AnimationStateData GetAnimationStateData() { public AnimationStateData GetAnimationStateData () {
if (stateData != null) if (stateData != null)
return stateData; return stateData;
GetSkeletonData(false); GetSkeletonData(false);

View File

@ -305,7 +305,7 @@ public class SkeletonRenderer : MonoBehaviour {
} else { } else {
// Too many vertices, zero the extra. // Too many vertices, zero the extra.
Vector3 zero = Vector3.zero; Vector3 zero = Vector3.zero;
for (int i = vertexCount, n = lastState.vertexCount ; i < n; i++) for (int i = vertexCount, n = lastState.vertexCount; i < n; i++)
vertices[i] = zero; vertices[i] = zero;
} }
lastState.vertexCount = vertexCount; lastState.vertexCount = vertexCount;
@ -575,7 +575,7 @@ public class SkeletonRenderer : MonoBehaviour {
useMesh1 = !useMesh1; useMesh1 = !useMesh1;
} }
private bool CheckIfMustUpdateMeshStructure(ExposedList<int> attachmentsTriangleCountTemp, ExposedList<bool> attachmentsFlipStateTemp, ExposedList<LastState.AddSubmeshArguments> addSubmeshArgumentsTemp) { private bool CheckIfMustUpdateMeshStructure (ExposedList<int> attachmentsTriangleCountTemp, ExposedList<bool> attachmentsFlipStateTemp, ExposedList<LastState.AddSubmeshArguments> addSubmeshArgumentsTemp) {
// Check if any mesh settings were changed // Check if any mesh settings were changed
bool mustUpdateMeshStructure = bool mustUpdateMeshStructure =
immutableTriangles != (useMesh1 ? lastState.immutableTrianglesMesh1 : lastState.immutableTrianglesMesh2); immutableTriangles != (useMesh1 ? lastState.immutableTrianglesMesh1 : lastState.immutableTrianglesMesh2);
@ -771,7 +771,7 @@ public class SkeletonRenderer : MonoBehaviour {
public int firstVertex; public int firstVertex;
public bool lastSubmesh; public bool lastSubmesh;
public AddSubmeshArguments(Material material, int startSlot, int endSlot, int triangleCount, int firstVertex, bool lastSubmesh) { public AddSubmeshArguments (Material material, int startSlot, int endSlot, int triangleCount, int firstVertex, bool lastSubmesh) {
this.material = material; this.material = material;
this.startSlot = startSlot; this.startSlot = startSlot;
this.endSlot = endSlot; this.endSlot = endSlot;
@ -780,7 +780,7 @@ public class SkeletonRenderer : MonoBehaviour {
this.lastSubmesh = lastSubmesh; this.lastSubmesh = lastSubmesh;
} }
public bool Equals(ref AddSubmeshArguments other) { public bool Equals (ref AddSubmeshArguments other) {
return return
!ReferenceEquals(material, null) && !ReferenceEquals(material, null) &&
!ReferenceEquals(other.material, null) && !ReferenceEquals(other.material, null) &&

View File

@ -61,7 +61,7 @@ public class SkeletonUtility : MonoBehaviour {
int v = 0; int v = 0;
for (int i = 0; i < floatCount; i += 2, v++) { for (int i = 0; i < floatCount; i += 2, v++) {
verts[v].x = floats[i]; verts[v].x = floats[i];
verts[v].y = floats[i+1]; verts[v].y = floats[i + 1];
} }
collider.SetPath(0, verts); collider.SetPath(0, verts);
@ -139,7 +139,7 @@ public class SkeletonUtility : MonoBehaviour {
public List<SkeletonUtilityBone> utilityBones = new List<SkeletonUtilityBone>(); public List<SkeletonUtilityBone> utilityBones = new List<SkeletonUtilityBone>();
[System.NonSerialized] [System.NonSerialized]
public List<SkeletonUtilityConstraint> utilityConstraints = new List<SkeletonUtilityConstraint>(); public List<SkeletonUtilityConstraint> utilityConstraints = new List<SkeletonUtilityConstraint>();
// Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable; // Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable;
protected bool hasTransformBones; protected bool hasTransformBones;
protected bool hasUtilityConstraints; protected bool hasUtilityConstraints;
@ -170,7 +170,7 @@ public class SkeletonUtility : MonoBehaviour {
void Start () { void Start () {
//recollect because order of operations failure when switching between game mode and edit mode... //recollect because order of operations failure when switching between game mode and edit mode...
// CollectBones(); // CollectBones();
} }
void OnDisable () { void OnDisable () {

View File

@ -34,7 +34,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
public bool scale; public bool scale;
public bool flip; public bool flip;
public bool flipX; public bool flipX;
[Range(0f,1f)] [Range(0f, 1f)]
public float overrideAlpha = 1; public float overrideAlpha = 1;
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary> /// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
@ -153,90 +153,90 @@ public class SkeletonUtilityBone : MonoBehaviour {
if (transformLerpComplete)
return;
if (parentReference == null) {
if (position) {
bone.x = Mathf.Lerp(bone.x, cachedTransform.localPosition.x, overrideAlpha);
bone.y = Mathf.Lerp(bone.y, cachedTransform.localPosition.y, overrideAlpha);
}
if (rotation) {
float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;
if (flip) {
if ((!flipX && bone.flipX)) {
angle -= flipCompensation;
}
//TODO fix this...
if (angle >= 360)
angle -= 360;
else if (angle <= -360)
angle += 360;
}
bone.Rotation = angle;
bone.RotationIK = angle;
}
if (scale) {
bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
}
if (flip) {
bone.flipX = flipX;
}
} else {
if (transformLerpComplete) if (transformLerpComplete)
return; return;
if (parentReference == null) { if (position) {
if (position) { Vector3 pos = parentReference.InverseTransformPoint(cachedTransform.position);
bone.x = Mathf.Lerp(bone.x, cachedTransform.localPosition.x, overrideAlpha); bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha);
bone.y = Mathf.Lerp(bone.y, cachedTransform.localPosition.y, overrideAlpha); bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha);
} }
if (rotation) { if (rotation) {
float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation; float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
if (flip) { if (flip) {
if ((!flipX && bone.flipX)) { if ((!flipX && bone.flipX)) {
angle -= flipCompensation; angle -= flipCompensation;
} }
//TODO fix this... //TODO fix this...
if (angle >= 360) if (angle >= 360)
angle -= 360; angle -= 360;
else if (angle <= -360) else if (angle <= -360)
angle += 360; angle += 360;
} }
bone.Rotation = angle; bone.Rotation = angle;
bone.RotationIK = angle; bone.RotationIK = angle;
} }
if (scale) { //TODO: Something about this
bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha); if (scale) {
bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha); bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
} nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
}
if (flip) {
bone.flipX = flipX; if (flip) {
} bone.flipX = flipX;
} else {
if (transformLerpComplete)
return;
if (position) {
Vector3 pos = parentReference.InverseTransformPoint(cachedTransform.position);
bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha);
bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha);
}
if (rotation) {
float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
if (flip) {
if ((!flipX && bone.flipX)) {
angle -= flipCompensation;
}
//TODO fix this...
if (angle >= 360)
angle -= 360;
else if (angle <= -360)
angle += 360;
}
bone.Rotation = angle;
bone.RotationIK = angle;
}
//TODO: Something about this
if (scale) {
bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
}
if (flip) {
bone.flipX = flipX;
}
} }
transformLerpComplete = true;
} }
transformLerpComplete = true;
}
} }
public void FlipX (bool state) { public void FlipX (bool state) {
@ -246,9 +246,9 @@ public class SkeletonUtilityBone : MonoBehaviour {
skeletonUtility.skeletonAnimation.LateUpdate(); skeletonUtility.skeletonAnimation.LateUpdate();
return; return;
} else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90) { } else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90) {
skeletonUtility.skeletonAnimation.LateUpdate(); skeletonUtility.skeletonAnimation.LateUpdate();
return; return;
} }
} }
bone.FlipX = state; bone.FlipX = state;

View File

@ -44,7 +44,7 @@ public class SkeletonUtilityKinematicShadow : MonoBehaviour {
if (hideShadow) if (hideShadow)
shadowRoot.hideFlags = HideFlags.HideInHierarchy; shadowRoot.hideFlags = HideFlags.HideInHierarchy;
if(parent == null) if (parent == null)
shadowRoot.transform.parent = transform.root; shadowRoot.transform.parent = transform.root;
else else
shadowRoot.transform.parent = parent; shadowRoot.transform.parent = parent;

View File

@ -21,7 +21,7 @@ public class SpineSlot : PropertyAttribute {
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback. /// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
/// </param> /// </param>
/// <param name="containsBoundingBoxes">Disables popup results that don't contain bounding box attachments when true.</param> /// <param name="containsBoundingBoxes">Disables popup results that don't contain bounding box attachments when true.</param>
public SpineSlot(string startsWith = "", string dataField = "", bool containsBoundingBoxes = false) { public SpineSlot (string startsWith = "", string dataField = "", bool containsBoundingBoxes = false) {
this.startsWith = startsWith; this.startsWith = startsWith;
this.dataField = dataField; this.dataField = dataField;
this.containsBoundingBoxes = containsBoundingBoxes; this.containsBoundingBoxes = containsBoundingBoxes;
@ -40,7 +40,7 @@ public class SpineSkin : PropertyAttribute {
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives) /// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback. /// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
/// </param> /// </param>
public SpineSkin(string startsWith = "", string dataField = "") { public SpineSkin (string startsWith = "", string dataField = "") {
this.startsWith = startsWith; this.startsWith = startsWith;
this.dataField = dataField; this.dataField = dataField;
} }
@ -57,7 +57,7 @@ public class SpineAnimation : PropertyAttribute {
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives) /// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback. /// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
/// </param> /// </param>
public SpineAnimation(string startsWith = "", string dataField = "") { public SpineAnimation (string startsWith = "", string dataField = "") {
this.startsWith = startsWith; this.startsWith = startsWith;
this.dataField = dataField; this.dataField = dataField;
} }
@ -71,7 +71,7 @@ public class SpineAttachment : PropertyAttribute {
public string slotField = ""; public string slotField = "";
public SpineAttachment() { public SpineAttachment () {
} }
@ -86,7 +86,7 @@ public class SpineAttachment : PropertyAttribute {
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives) /// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback. /// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
/// </param> /// </param>
public SpineAttachment(bool currentSkinOnly = true, bool returnAttachmentPath = false, bool placeholdersOnly = false, string slotField = "", string dataField = "") { public SpineAttachment (bool currentSkinOnly = true, bool returnAttachmentPath = false, bool placeholdersOnly = false, string slotField = "", string dataField = "") {
this.currentSkinOnly = currentSkinOnly; this.currentSkinOnly = currentSkinOnly;
this.returnAttachmentPath = returnAttachmentPath; this.returnAttachmentPath = returnAttachmentPath;
this.placeholdersOnly = placeholdersOnly; this.placeholdersOnly = placeholdersOnly;
@ -94,11 +94,11 @@ public class SpineAttachment : PropertyAttribute {
this.dataField = dataField; this.dataField = dataField;
} }
public static Hierarchy GetHierarchy(string fullPath) { public static Hierarchy GetHierarchy (string fullPath) {
return new Hierarchy(fullPath); return new Hierarchy(fullPath);
} }
public static Spine.Attachment GetAttachment(string attachmentPath, Spine.SkeletonData skeletonData) { public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) {
var hierarchy = SpineAttachment.GetHierarchy(attachmentPath); var hierarchy = SpineAttachment.GetHierarchy(attachmentPath);
if (hierarchy.name == "") if (hierarchy.name == "")
return null; return null;
@ -106,7 +106,7 @@ public class SpineAttachment : PropertyAttribute {
return skeletonData.FindSkin(hierarchy.skin).GetAttachment(skeletonData.FindSlotIndex(hierarchy.slot), hierarchy.name); return skeletonData.FindSkin(hierarchy.skin).GetAttachment(skeletonData.FindSlotIndex(hierarchy.slot), hierarchy.name);
} }
public static Spine.Attachment GetAttachment(string attachmentPath, SkeletonDataAsset skeletonDataAsset) { public static Spine.Attachment GetAttachment (string attachmentPath, SkeletonDataAsset skeletonDataAsset) {
return GetAttachment(attachmentPath, skeletonDataAsset.GetSkeletonData(true)); return GetAttachment(attachmentPath, skeletonDataAsset.GetSkeletonData(true));
} }
@ -115,15 +115,14 @@ public class SpineAttachment : PropertyAttribute {
public string slot; public string slot;
public string name; public string name;
public Hierarchy(string fullPath) { 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) { if (chunks.Length == 0) {
skin = ""; skin = "";
slot = ""; slot = "";
name = ""; name = "";
return; 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 + "]"); throw new System.Exception("Cannot generate Attachment Hierarchy from string! Not enough components! [" + fullPath + "]");
} }
skin = chunks[0]; skin = chunks[0];
@ -148,19 +147,19 @@ public class SpineBone : PropertyAttribute {
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives) /// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback. /// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
/// </param> /// </param>
public SpineBone(string startsWith = "", string dataField = "") { public SpineBone (string startsWith = "", string dataField = "") {
this.startsWith = startsWith; this.startsWith = startsWith;
this.dataField = dataField; this.dataField = dataField;
} }
public static Spine.Bone GetBone(string boneName, SkeletonRenderer renderer) { public static Spine.Bone GetBone (string boneName, SkeletonRenderer renderer) {
if (renderer.skeleton == null) if (renderer.skeleton == null)
return null; return null;
return renderer.skeleton.FindBone(boneName); return renderer.skeleton.FindBone(boneName);
} }
public static Spine.BoneData GetBoneData(string boneName, SkeletonDataAsset skeletonDataAsset) { public static Spine.BoneData GetBoneData (string boneName, SkeletonDataAsset skeletonDataAsset) {
var data = skeletonDataAsset.GetSkeletonData(true); var data = skeletonDataAsset.GetSkeletonData(true);
return data.FindBone(boneName); return data.FindBone(boneName);