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: { }
} }
} }
@ -181,7 +181,7 @@ namespace Spine {
drawOrder.Clear(); drawOrder.Clear();
for (int i = 0, n = slots.Count; i < n; i++) for (int i = 0, n = slots.Count; i < n; i++)
drawOrder.Add(slots.Items[i]); drawOrder.Add(slots.Items[i]);
for (int i = 0, n = slots.Count; i < n; i++) for (int i = 0, n = slots.Count; i < n; i++)
slots.Items[i].SetToSetupPose(i); slots.Items[i].SetToSetupPose(i);
} }

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;
} }
@ -343,7 +343,7 @@ namespace Spine {
var timelines = new ExposedList<Timeline>(); var timelines = new ExposedList<Timeline>();
float scale = Scale; float scale = Scale;
float duration = 0; float duration = 0;
// Slot timelines. // Slot timelines.
for (int i = 0, n = ReadInt(input, true); i < n; i++) { for (int i = 0, n = ReadInt(input, true); i < n; i++) {
int slotIndex = ReadInt(input, true); int slotIndex = ReadInt(input, true);
@ -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

@ -105,7 +105,7 @@ namespace Spine {
} }
// --- Skins. // --- Skins.
/// <returns>May be null.</returns> /// <returns>May be null.</returns>
public Skin FindSkin (String skinName) { public Skin FindSkin (String skinName) {
if (skinName == null) throw new ArgumentNullException("skinName cannot be null."); if (skinName == null) throw new ArgumentNullException("skinName cannot be null.");
@ -125,7 +125,7 @@ namespace Spine {
} }
// --- Animations. // --- Animations.
/// <returns>May be null.</returns> /// <returns>May be null.</returns>
public Animation FindAnimation (String animationName) { public Animation FindAnimation (String animationName) {
if (animationName == null) throw new ArgumentNullException("animationName cannot be null."); if (animationName == null) throw new ArgumentNullException("animationName cannot be null.");

View File

@ -256,7 +256,7 @@ namespace Spine {
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.vertices = GetFloatArray(map, "vertices", Scale); mesh.vertices = GetFloatArray(map, "vertices", Scale);
mesh.triangles = GetIntArray(map, "triangles"); mesh.triangles = GetIntArray(map, "triangles");
mesh.regionUVs = GetFloatArray(map, "uvs", 1); mesh.regionUVs = GetFloatArray(map, "uvs", 1);

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) {
@ -92,10 +92,10 @@ public class AtlasAsset : ScriptableObject {
mesh = new Mesh(); mesh = new Mesh();
mesh.name = name; mesh.name = name;
} }
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;
@ -118,7 +118,7 @@ public class AtlasAsset : ScriptableObject {
uvs[0] = new Vector2(u, v2); uvs[0] = new Vector2(u, v2);
uvs[1] = new Vector2(u, v); uvs[1] = new Vector2(u, v);
uvs[2] = new Vector2(u2, v); uvs[2] = new Vector2(u2, v);
uvs[3] = new Vector2(u2, v2); uvs[3] = new Vector2(u2, v2);
} else { } else {
uvs[0] = new Vector2(u2, v2); uvs[0] = new Vector2(u2, v2);
uvs[1] = new Vector2(u, v2); uvs[1] = new Vector2(u, v2);
@ -145,11 +145,11 @@ public class AtlasAsset : ScriptableObject {
public class MaterialsTextureLoader : TextureLoader { public class MaterialsTextureLoader : TextureLoader {
AtlasAsset atlasAsset; AtlasAsset atlasAsset;
public MaterialsTextureLoader (AtlasAsset atlasAsset) { public MaterialsTextureLoader (AtlasAsset atlasAsset) {
this.atlasAsset = atlasAsset; this.atlasAsset = atlasAsset;
} }
public void Load (AtlasPage page, String path) { public void Load (AtlasPage page, String path) {
String name = Path.GetFileNameWithoutExtension(path); String name = Path.GetFileNameWithoutExtension(path);
Material material = null; Material material = null;

View File

@ -50,14 +50,14 @@ 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);
float scaleMultiplier = skeletonRenderer.skeletonDataAsset.scale; float scaleMultiplier = skeletonRenderer.skeletonDataAsset.scale;

View File

@ -58,7 +58,7 @@ public class BoneFollower : MonoBehaviour {
/// <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>
[SpineBone(dataField: "skeletonRenderer")] [SpineBone(dataField: "skeletonRenderer")]
public String boneName; public String boneName;
public bool resetOnAwake = true; public bool resetOnAwake = true;

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

@ -24,7 +24,7 @@ public class SkeletonGhostRenderer : MonoBehaviour {
StopAllCoroutines(); StopAllCoroutines();
gameObject.SetActive(true); gameObject.SetActive(true);
meshRenderer.sharedMaterials = materials; meshRenderer.sharedMaterials = materials;
meshRenderer.sortingOrder = sortingOrder; meshRenderer.sortingOrder = sortingOrder;
@ -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++;
} }
@ -242,7 +242,7 @@ public class SkeletonRagdoll : MonoBehaviour {
Debug.LogWarning(msg); Debug.LogWarning(msg);
} }
} }
if (disableIK) { if (disableIK) {
foreach (IkConstraint ik in skeleton.IkConstraints) { foreach (IkConstraint ik in skeleton.IkConstraints) {
ik.Mix = 0; ik.Mix = 0;

View File

@ -42,7 +42,7 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation {
public bool loop; public bool loop;
public Spine.AnimationState state; public Spine.AnimationState state;
public event UpdateBonesDelegate UpdateLocal { public event UpdateBonesDelegate UpdateLocal {
add { _UpdateLocal += value; } add { _UpdateLocal += value; }
@ -114,17 +114,17 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation {
state.Update(deltaTime); state.Update(deltaTime);
state.Apply(skeleton); state.Apply(skeleton);
if (_UpdateLocal != null) if (_UpdateLocal != null)
_UpdateLocal(this); _UpdateLocal(this);
skeleton.UpdateWorldTransform(); skeleton.UpdateWorldTransform();
if (_UpdateWorld != null) { if (_UpdateWorld != null) {
_UpdateWorld(this); _UpdateWorld(this);
skeleton.UpdateWorldTransform(); skeleton.UpdateWorldTransform();
} }
if (_UpdateComplete != null) { if (_UpdateComplete != null) {
_UpdateComplete(this); _UpdateComplete(this);
} }
} }

View File

@ -81,7 +81,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
//apply //apply
int layerCount = animator.layerCount; int layerCount = animator.layerCount;
for (int i = 0; i < layerCount; i++) { for (int i = 0; i < layerCount; i++) {
float layerWeight = animator.GetLayerWeight(i); float layerWeight = animator.GetLayerWeight(i);
@ -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)
@ -98,7 +98,7 @@ public class SkeletonDataAsset : ScriptableObject {
if (skeletonData != null) if (skeletonData != null)
return skeletonData; return skeletonData;
AttachmentLoader attachmentLoader; AttachmentLoader attachmentLoader;
float skeletonDataScale; float skeletonDataScale;
@ -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

@ -17,7 +17,7 @@ public static class SkeletonExtensions {
skeleton.G = color.g; skeleton.G = color.g;
skeleton.B = color.b; skeleton.B = color.b;
} }
public static void SetColor (this Skeleton skeleton, Color32 color) { public static void SetColor (this Skeleton skeleton, Color32 color) {
skeleton.A = color.a / 255f; skeleton.A = color.a / 255f;
skeleton.R = color.r / 255f; skeleton.R = color.r / 255f;

View File

@ -211,7 +211,7 @@ public class SkeletonRenderer : MonoBehaviour {
int attachmentVertexCount, attachmentTriangleCount; int attachmentVertexCount, attachmentTriangleCount;
bool worldScaleXIsPositive = bone.worldScaleX >= 0f; bool worldScaleXIsPositive = bone.worldScaleX >= 0f;
bool worldScaleYIsPositive = bone.worldScaleY >= 0f; bool worldScaleYIsPositive = bone.worldScaleY >= 0f;
bool worldScaleIsSameSigns = (worldScaleXIsPositive && worldScaleYIsPositive) || bool worldScaleIsSameSigns = (worldScaleXIsPositive && worldScaleYIsPositive) ||
(!worldScaleXIsPositive && !worldScaleYIsPositive); (!worldScaleXIsPositive && !worldScaleYIsPositive);
bool flip = frontFacing && ((bone.worldFlipX != bone.worldFlipY) == worldScaleIsSameSigns); bool flip = frontFacing && ((bone.worldFlipX != bone.worldFlipY) == worldScaleIsSameSigns);
attachmentsFlipStateTemp.Items[i] = flip; attachmentsFlipStateTemp.Items[i] = flip;
@ -247,7 +247,7 @@ public class SkeletonRenderer : MonoBehaviour {
#else #else
Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
#endif #endif
if ((lastMaterial != null && lastMaterial.GetInstanceID() != material.GetInstanceID()) || if ((lastMaterial != null && lastMaterial.GetInstanceID() != material.GetInstanceID()) ||
(submeshSeparatorSlotsCount > 0 && submeshSeparatorSlots.Contains(slot))) { (submeshSeparatorSlotsCount > 0 && submeshSeparatorSlots.Contains(slot))) {
addSubmeshArgumentsTemp.Add( addSubmeshArgumentsTemp.Add(
new LastState.AddSubmeshArguments(lastMaterial, submeshStartSlotIndex, i, submeshTriangleCount, submeshFirstVertex, false) new LastState.AddSubmeshArguments(lastMaterial, submeshStartSlotIndex, i, submeshTriangleCount, submeshFirstVertex, false)
@ -266,7 +266,7 @@ public class SkeletonRenderer : MonoBehaviour {
addSubmeshArgumentsTemp.Add( addSubmeshArgumentsTemp.Add(
new LastState.AddSubmeshArguments(lastMaterial, submeshStartSlotIndex, drawOrderCount, submeshTriangleCount, submeshFirstVertex, true) new LastState.AddSubmeshArguments(lastMaterial, submeshStartSlotIndex, drawOrderCount, submeshTriangleCount, submeshFirstVertex, true)
); );
bool mustUpdateMeshStructure = CheckIfMustUpdateMeshStructure(attachmentsTriangleCountTemp, attachmentsFlipStateTemp, addSubmeshArgumentsTemp); bool mustUpdateMeshStructure = CheckIfMustUpdateMeshStructure(attachmentsTriangleCountTemp, attachmentsFlipStateTemp, addSubmeshArgumentsTemp);
if (mustUpdateMeshStructure) { if (mustUpdateMeshStructure) {
submeshMaterials.Clear(); submeshMaterials.Clear();
@ -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,14 +780,14 @@ 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) &&
material.GetInstanceID() == other.material.GetInstanceID() && material.GetInstanceID() == other.material.GetInstanceID() &&
startSlot == other.startSlot && startSlot == other.startSlot &&
endSlot == other.endSlot && endSlot == other.endSlot &&
triangleCount == other.triangleCount && triangleCount == other.triangleCount &&
firstVertex == other.firstVertex; firstVertex == other.firstVertex;
} }
} }

View File

@ -56,18 +56,18 @@ public class SkeletonUtility : MonoBehaviour {
float[] floats = boundingBox.Vertices; float[] floats = boundingBox.Vertices;
int floatCount = floats.Length; int floatCount = floats.Length;
int vertCount = floatCount / 2; int vertCount = floatCount / 2;
Vector2[] verts = new Vector2[vertCount]; Vector2[] verts = new Vector2[vertCount];
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);
return collider; return collider;
} }
return null; return null;
@ -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 () {
@ -182,7 +182,7 @@ public class SkeletonUtility : MonoBehaviour {
skeletonAnimation.UpdateComplete -= UpdateComplete; skeletonAnimation.UpdateComplete -= UpdateComplete;
} }
} }
void HandleRendererReset (SkeletonRenderer r) { void HandleRendererReset (SkeletonRenderer r) {
if (OnReset != null) if (OnReset != null)
OnReset(); OnReset();
@ -212,7 +212,7 @@ public class SkeletonUtility : MonoBehaviour {
needToReprocessBones = true; needToReprocessBones = true;
} }
} }
public void UnregisterConstraint (SkeletonUtilityConstraint constraint) { public void UnregisterConstraint (SkeletonUtilityConstraint constraint) {
utilityConstraints.Remove(constraint); utilityConstraints.Remove(constraint);
} }
@ -351,11 +351,11 @@ public class SkeletonUtility : MonoBehaviour {
return go; return go;
} }
public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) { public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
GameObject go = new GameObject(bone.Data.Name); GameObject go = new GameObject(bone.Data.Name);
go.transform.parent = parent; go.transform.parent = parent;
SkeletonUtilityBone b = go.AddComponent<SkeletonUtilityBone>(); SkeletonUtilityBone b = go.AddComponent<SkeletonUtilityBone>();
b.skeletonUtility = this; b.skeletonUtility = this;
b.position = pos; b.position = pos;
@ -371,16 +371,16 @@ public class SkeletonUtility : MonoBehaviour {
if (mode == SkeletonUtilityBone.Mode.Override) { if (mode == SkeletonUtilityBone.Mode.Override) {
if (rot) if (rot)
go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.RotationIK); go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.RotationIK);
if (pos) if (pos)
go.transform.localPosition = new Vector3(b.bone.X, b.bone.Y, 0); go.transform.localPosition = new Vector3(b.bone.X, b.bone.Y, 0);
go.transform.localScale = new Vector3(b.bone.scaleX, b.bone.scaleY, 0); go.transform.localScale = new Vector3(b.bone.scaleX, b.bone.scaleY, 0);
} }
return go; return go;
} }
public void SpawnSubRenderers (bool disablePrimaryRenderer) { public void SpawnSubRenderers (bool disablePrimaryRenderer) {
int submeshCount = GetComponent<MeshFilter>().sharedMesh.subMeshCount; int submeshCount = GetComponent<MeshFilter>().sharedMesh.subMeshCount;

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>
@ -109,10 +109,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
} }
} }
float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f; float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
float flipCompensation = 0; float flipCompensation = 0;
if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) { if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) {
flipCompensation = bone.parent.WorldRotation * -2; flipCompensation = bone.parent.WorldRotation * -2;
@ -133,7 +133,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
if (bone.Data.InheritRotation) { if (bone.Data.InheritRotation) {
if (bone.FlipX) { if (bone.FlipX) {
cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation); cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
} else { } else {
cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK); cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
} }
} else { } else {
@ -153,90 +153,90 @@ public class SkeletonUtilityBone : MonoBehaviour {
if (transformLerpComplete) if (transformLerpComplete)
return; 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)
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;
}
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);
} }
transformLerpComplete = true; 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)
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;
}
} }
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

@ -41,7 +41,7 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
public float speed = 10; public float speed = 10;
Vector3[] origins; Vector3[] origins;
Vector3 centerPoint; Vector3 centerPoint;
protected override void OnEnable () { protected override void OnEnable () {
if (!Application.isPlaying) if (!Application.isPlaying)
return; return;
@ -57,14 +57,14 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
centerPoint = centerBounds.center; centerPoint = centerBounds.center;
} }
protected override void OnDisable () { protected override void OnDisable () {
if (!Application.isPlaying) if (!Application.isPlaying)
return; return;
base.OnDisable(); base.OnDisable();
} }
public override void DoUpdate () { public override void DoUpdate () {
if (target != null) if (target != null)
@ -75,13 +75,13 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
Vector3 center = transform.TransformPoint(centerPoint); Vector3 center = transform.TransformPoint(centerPoint);
Vector3 dir = goal - center; Vector3 dir = goal - center;
if (dir.magnitude > 1) if (dir.magnitude > 1)
dir.Normalize(); dir.Normalize();
for (int i = 0; i < eyes.Length; i++) { for (int i = 0; i < eyes.Length; i++) {
center = transform.TransformPoint(origins[i]); center = transform.TransformPoint(origins[i]);
eyes[i].position = Vector3.MoveTowards(eyes[i].position, center + (dir * radius), speed * Time.deltaTime); eyes[i].position = Vector3.MoveTowards(eyes[i].position, center + (dir * radius), speed * Time.deltaTime);
} }
} }
} }

View File

@ -128,7 +128,7 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
Vector3 v = transform.position; Vector3 v = transform.position;
v.y = Mathf.Clamp(v.y, Mathf.Min(lastHitY, hitY), float.MaxValue); v.y = Mathf.Clamp(v.y, Mathf.Min(lastHitY, hitY), float.MaxValue);
transform.position = v; transform.position = v;
utilBone.bone.X = transform.localPosition.x; utilBone.bone.X = transform.localPosition.x;
utilBone.bone.Y = transform.localPosition.y; utilBone.bone.Y = transform.localPosition.y;

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,19 +86,19 @@ 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;
this.slotField = slotField; this.slotField = slotField;
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);