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 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 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 delegate void CompleteDelegate(AnimationState state, int trackIndex, int loopCount);
public delegate void CompleteDelegate (AnimationState state, int trackIndex, int loopCount);
public event CompleteDelegate Complete;
public AnimationState (AnimationStateData data) {

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -133,7 +133,7 @@ namespace Spine {
current = current.parent;
} while (current != null);
nonIkBones.Add(bone);
outer: {}
outer: { }
}
}
@ -181,7 +181,7 @@ namespace Spine {
drawOrder.Clear();
for (int i = 0, n = slots.Count; i < n; i++)
drawOrder.Add(slots.Items[i]);
for (int i = 0, n = slots.Count; i < n; i++)
slots.Items[i].SetToSetupPose(i);
}

View File

@ -217,95 +217,95 @@ namespace Spine {
switch ((AttachmentType)input.ReadByte()) {
case AttachmentType.region: {
String path = ReadString(input);
if (path == null) path = name;
RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path);
if (region == null) return null;
region.Path = path;
region.x = ReadFloat(input) * scale;
region.y = ReadFloat(input) * scale;
region.scaleX = ReadFloat(input);
region.scaleY = ReadFloat(input);
region.rotation = ReadFloat(input);
region.width = ReadFloat(input) * scale;
region.height = ReadFloat(input) * scale;
int color = ReadInt(input);
region.r = ((color & 0xff000000) >> 24) / 255f;
region.g = ((color & 0x00ff0000) >> 16) / 255f;
region.b = ((color & 0x0000ff00) >> 8) / 255f;
region.a = ((color & 0x000000ff)) / 255f;
region.UpdateOffset();
return region;
}
String path = ReadString(input);
if (path == null) path = name;
RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path);
if (region == null) return null;
region.Path = path;
region.x = ReadFloat(input) * scale;
region.y = ReadFloat(input) * scale;
region.scaleX = ReadFloat(input);
region.scaleY = ReadFloat(input);
region.rotation = ReadFloat(input);
region.width = ReadFloat(input) * scale;
region.height = ReadFloat(input) * scale;
int color = ReadInt(input);
region.r = ((color & 0xff000000) >> 24) / 255f;
region.g = ((color & 0x00ff0000) >> 16) / 255f;
region.b = ((color & 0x0000ff00) >> 8) / 255f;
region.a = ((color & 0x000000ff)) / 255f;
region.UpdateOffset();
return region;
}
case AttachmentType.boundingbox: {
BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name);
if (box == null) return null;
box.vertices = ReadFloatArray(input, scale);
return box;
}
BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name);
if (box == null) return null;
box.vertices = ReadFloatArray(input, scale);
return box;
}
case AttachmentType.mesh: {
String path = ReadString(input);
if (path == null) path = name;
MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
if (mesh == null) return null;
mesh.Path = path;
mesh.regionUVs = ReadFloatArray(input, 1);
mesh.triangles = ReadShortArray(input);
mesh.vertices = ReadFloatArray(input, scale);
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;
}
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));
String path = ReadString(input);
if (path == null) path = name;
MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
if (mesh == null) return null;
mesh.Path = path;
mesh.regionUVs = ReadFloatArray(input, 1);
mesh.triangles = ReadShortArray(input);
mesh.vertices = ReadFloatArray(input, scale);
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;
}
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;
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));
}
}
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;
}
@ -343,7 +343,7 @@ namespace Spine {
var timelines = new ExposedList<Timeline>();
float scale = Scale;
float duration = 0;
// Slot timelines.
for (int i = 0, n = ReadInt(input, true); i < n; i++) {
int slotIndex = ReadInt(input, true);
@ -352,31 +352,31 @@ namespace Spine {
int frameCount = ReadInt(input, true);
switch (timelineType) {
case TIMELINE_COLOR: {
ColorTimeline timeline = new ColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
float time = ReadFloat(input);
int color = ReadInt(input);
float r = ((color & 0xff000000) >> 24) / 255f;
float g = ((color & 0x00ff0000) >> 16) / 255f;
float b = ((color & 0x0000ff00) >> 8) / 255f;
float a = ((color & 0x000000ff)) / 255f;
timeline.SetFrame(frameIndex, time, r, g, b, a);
if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline);
ColorTimeline timeline = new ColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
float time = ReadFloat(input);
int color = ReadInt(input);
float r = ((color & 0xff000000) >> 24) / 255f;
float g = ((color & 0x00ff0000) >> 16) / 255f;
float b = ((color & 0x0000ff00) >> 8) / 255f;
float a = ((color & 0x000000ff)) / 255f;
timeline.SetFrame(frameIndex, time, r, g, b, a);
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: {
AttachmentTimeline timeline = new AttachmentTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.SetFrame(frameIndex, ReadFloat(input), ReadString(input));
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount - 1]);
break;
}
AttachmentTimeline timeline = new AttachmentTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.SetFrame(frameIndex, ReadFloat(input), ReadString(input));
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount - 1]);
break;
}
}
}
}
@ -389,47 +389,47 @@ namespace Spine {
int frameCount = ReadInt(input, true);
switch (timelineType) {
case TIMELINE_ROTATE: {
RotateTimeline timeline = new RotateTimeline(frameCount);
timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input));
if (frameIndex < frameCount - 1) ReadCurve(input, frameIndex, timeline);
RotateTimeline timeline = new RotateTimeline(frameCount);
timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input));
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_SCALE: {
TranslateTimeline timeline;
float timelineScale = 1;
if (timelineType == TIMELINE_SCALE)
timeline = new ScaleTimeline(frameCount);
else {
timeline = new TranslateTimeline(frameCount);
timelineScale = scale;
TranslateTimeline timeline;
float timelineScale = 1;
if (timelineType == TIMELINE_SCALE)
timeline = new ScaleTimeline(frameCount);
else {
timeline = new TranslateTimeline(frameCount);
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_FLIPY: {
FlipXTimeline timeline = timelineType == TIMELINE_FLIPX ? new FlipXTimeline(frameCount) : new FlipYTimeline(
frameCount);
timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.SetFrame(frameIndex, ReadFloat(input), ReadBoolean(input));
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 2 - 2]);
break;
}
FlipXTimeline timeline = timelineType == TIMELINE_FLIPX ? new FlipXTimeline(frameCount) : new FlipYTimeline(
frameCount);
timeline.boneIndex = boneIndex;
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.SetFrame(frameIndex, ReadFloat(input), ReadBoolean(input));
timelines.Add(timeline);
duration = Math.Max(duration, timeline.frames[frameCount * 2 - 2]);
break;
}
}
}
}

View File

@ -105,7 +105,7 @@ namespace Spine {
}
// --- Skins.
/// <returns>May be null.</returns>
public Skin FindSkin (String skinName) {
if (skinName == null) throw new ArgumentNullException("skinName cannot be null.");
@ -125,7 +125,7 @@ namespace Spine {
}
// --- Animations.
/// <returns>May be null.</returns>
public Animation FindAnimation (String animationName) {
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);
if (mesh == null) return null;
mesh.Path = path;
mesh.Path = path;
mesh.vertices = GetFloatArray(map, "vertices", Scale);
mesh.triangles = GetIntArray(map, "triangles");
mesh.regionUVs = GetFloatArray(map, "uvs", 1);

View File

@ -91,7 +91,7 @@ namespace Spine {
internal static readonly AttachmentKeyTupleComparer Instance = new AttachmentKeyTupleComparer();
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) {
@ -99,16 +99,16 @@ namespace Spine {
}
}
private class AttachmentKeyTuple {
public readonly int SlotIndex;
public readonly string Name;
public readonly int NameHashCode;
private class AttachmentKeyTuple {
public readonly int SlotIndex;
public readonly string Name;
public readonly int NameHashCode;
public AttachmentKeyTuple(int slotIndex, string name) {
SlotIndex = slotIndex;
Name = name;
NameHashCode = Name.GetHashCode();
}
}
public AttachmentKeyTuple (int slotIndex, string name) {
SlotIndex = slotIndex;
Name = name;
NameHashCode = Name.GetHashCode();
}
}
}
}

View File

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

View File

@ -50,14 +50,14 @@ public class AtlasRegionAttacher : MonoBehaviour {
Atlas atlas;
void Awake() {
void Awake () {
GetComponent<SkeletonRenderer>().OnReset += Apply;
}
void Apply(SkeletonRenderer skeletonRenderer) {
void Apply (SkeletonRenderer skeletonRenderer) {
atlas = atlasAsset.GetAtlas();
AtlasAttachmentLoader loader = new AtlasAttachmentLoader(atlas);
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>
[SpineBone(dataField: "skeletonRenderer")]
public String boneName;
public bool resetOnAwake = true;

View File

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

View File

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

View File

@ -67,7 +67,7 @@ public class SkeletonRagdoll : MonoBehaviour {
private Rigidbody rootRigidbody;
private ISkeletonAnimation skeletonAnim;
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 Transform ragdollRoot;
private Vector3 rootOffset;
@ -121,7 +121,7 @@ public class SkeletonRagdoll : MonoBehaviour {
Rigidbody[] arr = new Rigidbody[boneTable.Count];
int i = 0;
foreach(Transform t in boneTable.Values){
foreach (Transform t in boneTable.Values) {
arr[i] = t.GetComponent<Rigidbody>();
i++;
}
@ -242,7 +242,7 @@ public class SkeletonRagdoll : MonoBehaviour {
Debug.LogWarning(msg);
}
}
if (disableIK) {
foreach (IkConstraint ik in skeleton.IkConstraints) {
ik.Mix = 0;

View File

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

View File

@ -81,7 +81,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
//apply
int layerCount = animator.layerCount;
for (int i = 0; i < layerCount; i++) {
float layerWeight = animator.GetLayerWeight(i);
@ -191,7 +191,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
lastTime = Time.time;
}
private int GetAnimationClipNameHashCode(AnimationClip clip) {
private int GetAnimationClipNameHashCode (AnimationClip clip) {
int clipNameHashCode;
if (!clipNameHashCodeTable.TryGetValue(clip, out clipNameHashCode)) {
clipNameHashCode = clip.name.GetHashCode();

View File

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

View File

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

View File

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

View File

@ -56,18 +56,18 @@ public class SkeletonUtility : MonoBehaviour {
float[] floats = boundingBox.Vertices;
int floatCount = floats.Length;
int vertCount = floatCount / 2;
Vector2[] verts = new Vector2[vertCount];
int v = 0;
for (int i = 0; i < floatCount; i += 2, v++) {
verts[v].x = floats[i];
verts[v].y = floats[i+1];
verts[v].y = floats[i + 1];
}
collider.SetPath(0, verts);
return collider;
}
return null;
@ -139,7 +139,7 @@ public class SkeletonUtility : MonoBehaviour {
public List<SkeletonUtilityBone> utilityBones = new List<SkeletonUtilityBone>();
[System.NonSerialized]
public List<SkeletonUtilityConstraint> utilityConstraints = new List<SkeletonUtilityConstraint>();
// Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable;
// Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable;
protected bool hasTransformBones;
protected bool hasUtilityConstraints;
@ -170,7 +170,7 @@ public class SkeletonUtility : MonoBehaviour {
void Start () {
//recollect because order of operations failure when switching between game mode and edit mode...
// CollectBones();
// CollectBones();
}
void OnDisable () {
@ -182,7 +182,7 @@ public class SkeletonUtility : MonoBehaviour {
skeletonAnimation.UpdateComplete -= UpdateComplete;
}
}
void HandleRendererReset (SkeletonRenderer r) {
if (OnReset != null)
OnReset();
@ -212,7 +212,7 @@ public class SkeletonUtility : MonoBehaviour {
needToReprocessBones = true;
}
}
public void UnregisterConstraint (SkeletonUtilityConstraint constraint) {
utilityConstraints.Remove(constraint);
}
@ -351,11 +351,11 @@ public class SkeletonUtility : MonoBehaviour {
return go;
}
public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
GameObject go = new GameObject(bone.Data.Name);
go.transform.parent = parent;
SkeletonUtilityBone b = go.AddComponent<SkeletonUtilityBone>();
b.skeletonUtility = this;
b.position = pos;
@ -371,16 +371,16 @@ public class SkeletonUtility : MonoBehaviour {
if (mode == SkeletonUtilityBone.Mode.Override) {
if (rot)
go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.RotationIK);
if (pos)
go.transform.localPosition = new Vector3(b.bone.X, b.bone.Y, 0);
go.transform.localScale = new Vector3(b.bone.scaleX, b.bone.scaleY, 0);
}
return go;
}
public void SpawnSubRenderers (bool disablePrimaryRenderer) {
int submeshCount = GetComponent<MeshFilter>().sharedMesh.subMeshCount;

View File

@ -34,7 +34,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
public bool scale;
public bool flip;
public bool flipX;
[Range(0f,1f)]
[Range(0f, 1f)]
public float overrideAlpha = 1;
/// <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 flipCompensation = 0;
if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) {
flipCompensation = bone.parent.WorldRotation * -2;
@ -133,7 +133,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
if (bone.Data.InheritRotation) {
if (bone.FlipX) {
cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
} else {
} else {
cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
}
} else {
@ -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)
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 (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);
}
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) {
@ -246,9 +246,9 @@ public class SkeletonUtilityBone : MonoBehaviour {
skeletonUtility.skeletonAnimation.LateUpdate();
return;
} else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90) {
skeletonUtility.skeletonAnimation.LateUpdate();
return;
}
skeletonUtility.skeletonAnimation.LateUpdate();
return;
}
}
bone.FlipX = state;

View File

@ -41,7 +41,7 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
public float speed = 10;
Vector3[] origins;
Vector3 centerPoint;
protected override void OnEnable () {
if (!Application.isPlaying)
return;
@ -57,14 +57,14 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
centerPoint = centerBounds.center;
}
protected override void OnDisable () {
if (!Application.isPlaying)
return;
base.OnDisable();
}
public override void DoUpdate () {
if (target != null)
@ -75,13 +75,13 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
Vector3 center = transform.TransformPoint(centerPoint);
Vector3 dir = goal - center;
if (dir.magnitude > 1)
if (dir.magnitude > 1)
dir.Normalize();
for (int i = 0; i < eyes.Length; i++) {
center = transform.TransformPoint(origins[i]);
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;
v.y = Mathf.Clamp(v.y, Mathf.Min(lastHitY, hitY), float.MaxValue);
transform.position = v;
utilBone.bone.X = transform.localPosition.x;
utilBone.bone.Y = transform.localPosition.y;

View File

@ -44,7 +44,7 @@ public class SkeletonUtilityKinematicShadow : MonoBehaviour {
if (hideShadow)
shadowRoot.hideFlags = HideFlags.HideInHierarchy;
if(parent == null)
if (parent == null)
shadowRoot.transform.parent = transform.root;
else
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.
/// </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.dataField = dataField;
this.containsBoundingBoxes = containsBoundingBoxes;
@ -40,7 +40,7 @@ public class SpineSkin : PropertyAttribute {
/// 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.
/// </param>
public SpineSkin(string startsWith = "", string dataField = "") {
public SpineSkin (string startsWith = "", string dataField = "") {
this.startsWith = startsWith;
this.dataField = dataField;
}
@ -57,7 +57,7 @@ public class SpineAnimation : PropertyAttribute {
/// 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.
/// </param>
public SpineAnimation(string startsWith = "", string dataField = "") {
public SpineAnimation (string startsWith = "", string dataField = "") {
this.startsWith = startsWith;
this.dataField = dataField;
}
@ -71,7 +71,7 @@ public class SpineAttachment : PropertyAttribute {
public string slotField = "";
public SpineAttachment() {
public SpineAttachment () {
}
@ -86,19 +86,19 @@ public class SpineAttachment : PropertyAttribute {
/// 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.
/// </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.returnAttachmentPath = returnAttachmentPath;
this.placeholdersOnly = placeholdersOnly;
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);
}
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);
if (hierarchy.name == "")
return null;
@ -106,7 +106,7 @@ public class SpineAttachment : PropertyAttribute {
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));
}
@ -115,15 +115,14 @@ public class SpineAttachment : PropertyAttribute {
public string slot;
public string name;
public Hierarchy(string fullPath) {
string[] chunks = fullPath.Split(new char[]{'/'}, System.StringSplitOptions.RemoveEmptyEntries);
public Hierarchy (string fullPath) {
string[] chunks = fullPath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries);
if (chunks.Length == 0) {
skin = "";
slot = "";
name = "";
return;
}
else if (chunks.Length < 2) {
} else if (chunks.Length < 2) {
throw new System.Exception("Cannot generate Attachment Hierarchy from string! Not enough components! [" + fullPath + "]");
}
skin = chunks[0];
@ -148,19 +147,19 @@ public class SpineBone : PropertyAttribute {
/// 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.
/// </param>
public SpineBone(string startsWith = "", string dataField = "") {
public SpineBone (string startsWith = "", string dataField = "") {
this.startsWith = startsWith;
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)
return null;
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);
return data.FindBone(boneName);