replace some more List<T> with ExposedList<T>

fix some stupidity from previous commit
This commit is contained in:
ZimM 2015-02-26 05:37:28 +02:00
parent 9ae48c2aac
commit 0635c19fef
17 changed files with 804 additions and 775 deletions

View File

@ -33,15 +33,15 @@ using System.Collections.Generic;
namespace Spine { namespace Spine {
public class Animation { public class Animation {
internal List<Timeline> timelines; internal ExposedList<Timeline> timelines;
internal float duration; internal float duration;
internal String name; internal String name;
public String Name { get { return name; } } public String Name { get { return name; } }
public List<Timeline> Timelines { get { return timelines; } set { timelines = value; } } public ExposedList<Timeline> Timelines { get { return timelines; } set { timelines = value; } }
public float Duration { get { return duration; } set { duration = value; } } public float Duration { get { return duration; } set { duration = value; } }
public Animation (String name, List<Timeline> timelines, float duration) { public Animation (String name, ExposedList<Timeline> timelines, float duration) {
if (name == null) throw new ArgumentNullException("name cannot be null."); if (name == null) throw new ArgumentNullException("name cannot be null.");
if (timelines == null) throw new ArgumentNullException("timelines cannot be null."); if (timelines == null) throw new ArgumentNullException("timelines cannot be null.");
this.name = name; this.name = name;
@ -52,7 +52,7 @@ namespace Spine {
/// <summary>Poses the skeleton at the specified time for this animation.</summary> /// <summary>Poses the skeleton at the specified time for this animation.</summary>
/// <param name="lastTime">The last time the animation was applied.</param> /// <param name="lastTime">The last time the animation was applied.</param>
/// <param name="events">Any triggered events are added.</param> /// <param name="events">Any triggered events are added.</param>
public void Apply (Skeleton skeleton, float lastTime, float time, bool loop, List<Event> events) { public void Apply (Skeleton skeleton, float lastTime, float time, bool loop, ExposedList<Event> events) {
if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null."); if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
if (loop && duration != 0) { if (loop && duration != 0) {
@ -60,16 +60,16 @@ namespace Spine {
lastTime %= duration; lastTime %= duration;
} }
List<Timeline> timelines = this.timelines; ExposedList<Timeline> timelines = this.timelines;
for (int i = 0, n = timelines.Count; i < n; i++) for (int i = 0, n = timelines.Count; i < n; i++)
timelines[i].Apply(skeleton, lastTime, time, events, 1); timelines.Items[i].Apply(skeleton, lastTime, time, events, 1);
} }
/// <summary>Poses the skeleton at the specified time for this animation mixed with the current pose.</summary> /// <summary>Poses the skeleton at the specified time for this animation mixed with the current pose.</summary>
/// <param name="lastTime">The last time the animation was applied.</param> /// <param name="lastTime">The last time the animation was applied.</param>
/// <param name="events">Any triggered events are added.</param> /// <param name="events">Any triggered events are added.</param>
/// <param name="alpha">The amount of this animation that affects the current pose.</param> /// <param name="alpha">The amount of this animation that affects the current pose.</param>
public void Mix (Skeleton skeleton, float lastTime, float time, bool loop, List<Event> events, float alpha) { public void Mix (Skeleton skeleton, float lastTime, float time, bool loop, ExposedList<Event> events, float alpha) {
if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null."); if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
if (loop && duration != 0) { if (loop && duration != 0) {
@ -77,9 +77,9 @@ namespace Spine {
lastTime %= duration; lastTime %= duration;
} }
List<Timeline> timelines = this.timelines; ExposedList<Timeline> timelines = this.timelines;
for (int i = 0, n = timelines.Count; i < n; i++) for (int i = 0, n = timelines.Count; i < n; i++)
timelines[i].Apply(skeleton, lastTime, time, events, alpha); timelines.Items[i].Apply(skeleton, lastTime, time, events, alpha);
} }
/// <param name="target">After the first and before the last entry.</param> /// <param name="target">After the first and before the last entry.</param>
@ -124,7 +124,7 @@ namespace Spine {
public interface Timeline { public interface Timeline {
/// <summary>Sets the value(s) for the specified time.</summary> /// <summary>Sets the value(s) for the specified time.</summary>
/// <param name="events">May be null to not collect fired events.</param> /// <param name="events">May be null to not collect fired events.</param>
void Apply (Skeleton skeleton, float lastTime, float time, List<Event> events, float alpha); void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> events, float alpha);
} }
/// <summary>Base class for frames that use an interpolation bezier curve.</summary> /// <summary>Base class for frames that use an interpolation bezier curve.</summary>
@ -139,7 +139,7 @@ namespace Spine {
curves = new float[(frameCount - 1) * BEZIER_SIZE]; curves = new float[(frameCount - 1) * BEZIER_SIZE];
} }
abstract public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha); abstract public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha);
public void SetLinear (int frameIndex) { public void SetLinear (int frameIndex) {
curves[frameIndex * BEZIER_SIZE] = LINEAR; curves[frameIndex * BEZIER_SIZE] = LINEAR;
@ -229,7 +229,7 @@ namespace Spine {
frames[frameIndex + 1] = angle; frames[frameIndex + 1] = angle;
} }
override public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
@ -292,7 +292,7 @@ namespace Spine {
frames[frameIndex + 2] = y; frames[frameIndex + 2] = y;
} }
override public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
@ -322,7 +322,7 @@ namespace Spine {
: base(frameCount) { : base(frameCount) {
} }
override public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
@ -374,7 +374,7 @@ namespace Spine {
frames[frameIndex + 4] = a; frames[frameIndex + 4] = a;
} }
override public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
@ -438,7 +438,7 @@ namespace Spine {
attachmentNames[frameIndex] = attachmentName; attachmentNames[frameIndex] = attachmentName;
} }
public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (lastTime > time) Apply(skeleton, lastTime, int.MaxValue, null, 0); if (lastTime > time) Apply(skeleton, lastTime, int.MaxValue, null, 0);
@ -475,7 +475,7 @@ namespace Spine {
} }
/// <summary>Fires events for frames > lastTime and <= time.</summary> /// <summary>Fires events for frames > lastTime and <= time.</summary>
public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
if (firedEvents == null) return; if (firedEvents == null) return;
float[] frames = this.frames; float[] frames = this.frames;
int frameCount = frames.Length; int frameCount = frames.Length;
@ -523,7 +523,7 @@ namespace Spine {
drawOrders[frameIndex] = drawOrder; drawOrders[frameIndex] = drawOrder;
} }
public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
@ -570,7 +570,7 @@ namespace Spine {
frameVertices[frameIndex] = vertices; frameVertices[frameIndex] = vertices;
} }
override public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
Slot slot = skeleton.slots.Items[slotIndex]; Slot slot = skeleton.slots.Items[slotIndex];
if (slot.attachment != attachment) return; if (slot.attachment != attachment) return;
@ -649,7 +649,7 @@ namespace Spine {
frames[frameIndex + 2] = bendDirection; frames[frameIndex + 2] = bendDirection;
} }
override public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
@ -693,7 +693,7 @@ namespace Spine {
frames[frameIndex + 1] = flip ? 1 : 0; frames[frameIndex + 1] = flip ? 1 : 0;
} }
public void Apply (Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha) { public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha) {
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (lastTime > time) Apply(skeleton, lastTime, int.MaxValue, null, 0); if (lastTime > time) Apply(skeleton, lastTime, int.MaxValue, null, 0);

View File

@ -35,8 +35,8 @@ using System.Text;
namespace Spine { namespace Spine {
public class AnimationState { public class AnimationState {
private AnimationStateData data; private AnimationStateData data;
private List<TrackEntry> tracks = new List<TrackEntry>(); private ExposedList<TrackEntry> tracks = new ExposedList<TrackEntry>();
private List<Event> events = new List<Event>(); private ExposedList<Event> events = new ExposedList<Event>();
private float timeScale = 1; private float timeScale = 1;
public AnimationStateData Data { get { return data; } } public AnimationStateData Data { get { return data; } }
@ -60,7 +60,7 @@ namespace Spine {
public void Update (float delta) { public void Update (float delta) {
delta *= timeScale; delta *= timeScale;
for (int i = 0; i < tracks.Count; i++) { for (int i = 0; i < tracks.Count; i++) {
TrackEntry current = tracks[i]; TrackEntry current = tracks.Items[i];
if (current == null) continue; if (current == null) continue;
float trackDelta = delta * current.timeScale; float trackDelta = delta * current.timeScale;
@ -92,10 +92,10 @@ namespace Spine {
} }
public void Apply (Skeleton skeleton) { public void Apply (Skeleton skeleton) {
List<Event> events = this.events; ExposedList<Event> events = this.events;
for (int i = 0; i < tracks.Count; i++) { for (int i = 0; i < tracks.Count; i++) {
TrackEntry current = tracks[i]; TrackEntry current = tracks.Items[i];
if (current == null) continue; if (current == null) continue;
events.Clear(); events.Clear();
@ -124,7 +124,7 @@ namespace Spine {
} }
for (int ii = 0, nn = events.Count; ii < nn; ii++) { for (int ii = 0, nn = events.Count; ii < nn; ii++) {
Event e = events[ii]; Event e = events.Items[ii];
current.OnEvent(this, i, e); current.OnEvent(this, i, e);
if (Event != null) Event(this, i, e); if (Event != null) Event(this, i, e);
} }
@ -141,17 +141,17 @@ namespace Spine {
public void ClearTrack (int trackIndex) { public void ClearTrack (int trackIndex) {
if (trackIndex >= tracks.Count) return; if (trackIndex >= tracks.Count) return;
TrackEntry current = tracks[trackIndex]; TrackEntry current = tracks.Items[trackIndex];
if (current == null) return; if (current == null) return;
current.OnEnd(this, trackIndex); current.OnEnd(this, trackIndex);
if (End != null) End(this, trackIndex); if (End != null) End(this, trackIndex);
tracks[trackIndex] = null; tracks.Items[trackIndex] = null;
} }
private TrackEntry ExpandToIndex (int index) { private TrackEntry ExpandToIndex (int index) {
if (index < tracks.Count) return tracks[index]; if (index < tracks.Count) return tracks.Items[index];
while (index >= tracks.Count) while (index >= tracks.Count)
tracks.Add(null); tracks.Add(null);
return null; return null;
@ -177,7 +177,7 @@ namespace Spine {
} }
} }
tracks[index] = entry; tracks.Items[index] = entry;
entry.OnStart(this, index); entry.OnStart(this, index);
if (Start != null) Start(this, index); if (Start != null) Start(this, index);
@ -223,7 +223,7 @@ namespace Spine {
last = last.next; last = last.next;
last.next = entry; last.next = entry;
} else } else
tracks[trackIndex] = entry; tracks.Items[trackIndex] = entry;
if (delay <= 0) { if (delay <= 0) {
if (last != null) if (last != null)
@ -239,13 +239,13 @@ namespace Spine {
/// <returns>May be null.</returns> /// <returns>May be null.</returns>
public TrackEntry GetCurrent (int trackIndex) { public TrackEntry GetCurrent (int trackIndex) {
if (trackIndex >= tracks.Count) return null; if (trackIndex >= tracks.Count) return null;
return tracks[trackIndex]; return tracks.Items[trackIndex];
} }
override public String ToString () { override public String ToString () {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
for (int i = 0, n = tracks.Count; i < n; i++) { for (int i = 0, n = tracks.Count; i < n; i++) {
TrackEntry entry = tracks[i]; TrackEntry entry = tracks.Items[i];
if (entry == null) continue; if (entry == null) continue;
if (buffer.Length > 0) buffer.Append(", "); if (buffer.Length > 0) buffer.Append(", ");
buffer.Append(entry.ToString()); buffer.Append(entry.ToString());

View File

@ -7,17 +7,17 @@ namespace Spine {
/// </summary> /// </summary>
/// <typeparam name="T">The type of elements in the list.</typeparam> /// <typeparam name="T">The type of elements in the list.</typeparam>
public class ExposedList<T> : IEnumerable<T> { public class ExposedList<T> : IEnumerable<T> {
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];
public T[] Items; public T[] Items;
private int _size; private int size;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="T:System.Collections.Generic.List`1" /> class that is empty and has the default initial capacity. /// Initializes a new instance of the <see cref="T:System.Collections.Generic.List`1" /> class that is empty and has the default initial capacity.
/// </summary> /// </summary>
public ExposedList() { public ExposedList() {
Items = _emptyArray; Items = emptyArray;
} }
/// <summary> /// <summary>
@ -34,6 +34,34 @@ namespace Spine {
Items = new T[capacity]; Items = new T[capacity];
} }
// Constructs a List, copying the contents of the given collection. The
// size and capacity of the new list will both be equal to the size of the
// given collection.
//
public ExposedList(IEnumerable<T> collection) {
if (collection==null)
throw new ArgumentNullException("collection");
ICollection<T> c = collection as ICollection<T>;
if( c != null) {
int count = c.Count;
Items = new T[count];
c.CopyTo(Items, 0);
size = count;
}
else {
size = 0;
Items = new T[defaultCapacity];
using(IEnumerator<T> en = collection.GetEnumerator()) {
while(en.MoveNext()) {
Add(en.Current);
}
}
}
}
/// <summary> /// <summary>
/// Gets or sets the total number of elements the internal data structure can hold without resizing. /// Gets or sets the total number of elements the internal data structure can hold without resizing.
/// </summary> /// </summary>
@ -55,17 +83,17 @@ namespace Spine {
if (value == Items.Length) { if (value == Items.Length) {
return; return;
} }
if (value < _size) { if (value < size) {
throw new ArgumentOutOfRangeException("value"); throw new ArgumentOutOfRangeException("value");
} }
if (value > 0) { if (value > 0) {
var objArray = new T[value]; var objArray = new T[value];
if (_size > 0) { if (size > 0) {
Array.Copy(Items, 0, objArray, 0, _size); Array.Copy(Items, 0, objArray, 0, size);
} }
Items = objArray; Items = objArray;
} else { } else {
Items = _emptyArray; Items = emptyArray;
} }
} }
} }
@ -78,7 +106,7 @@ namespace Spine {
/// </returns> /// </returns>
public int Count { public int Count {
get { get {
return _size; return size;
} }
} }
@ -89,19 +117,19 @@ namespace Spine {
/// The object to be added to the end of the <see cref="T:System.Collections.Generic.List`1" />. The value can be null for reference types. /// The object to be added to the end of the <see cref="T:System.Collections.Generic.List`1" />. The value can be null for reference types.
/// </param> /// </param>
public void Add(T item) { public void Add(T item) {
if (_size == Items.Length) { if (size == Items.Length) {
EnsureCapacity(_size + 1); EnsureCapacity(size + 1);
} }
Items[_size++] = item; Items[size++] = item;
} }
/// <summary> /// <summary>
/// Removes all elements from the <see cref="T:System.Collections.Generic.List`1" />. /// Removes all elements from the <see cref="T:System.Collections.Generic.List`1" />.
/// </summary> /// </summary>
public void Clear() { public void Clear() {
if (_size > 0) { if (size > 0) {
Array.Clear(Items, 0, _size); Array.Clear(Items, 0, size);
_size = 0; size = 0;
} }
} }
@ -116,7 +144,7 @@ namespace Spine {
/// </param> /// </param>
public bool Contains(T item) { public bool Contains(T item) {
if (item == null) { if (item == null) {
for (int index = 0; index < _size; ++index) { for (int index = 0; index < size; ++index) {
if (Items[index] == null) { if (Items[index] == null) {
return true; return true;
} }
@ -124,7 +152,7 @@ namespace Spine {
return false; return false;
} else { } else {
EqualityComparer<T> @default = EqualityComparer<T>.Default; EqualityComparer<T> @default = EqualityComparer<T>.Default;
for (int index = 0; index < _size; ++index) { for (int index = 0; index < size; ++index) {
if (@default.Equals(Items[index], item)) { if (@default.Equals(Items[index], item)) {
return true; return true;
} }
@ -158,7 +186,7 @@ namespace Spine {
/// to the end of the destination <paramref name="array" />. /// to the end of the destination <paramref name="array" />.
/// </exception> /// </exception>
public void CopyTo(T[] array, int arrayIndex) { public void CopyTo(T[] array, int arrayIndex) {
Array.Copy(Items, 0, array, arrayIndex, _size); Array.Copy(Items, 0, array, arrayIndex, size);
} }
/// <summary> /// <summary>
@ -177,7 +205,7 @@ namespace Spine {
/// The object to locate in the <see cref="T:System.Collections.Generic.List`1" />. The value can be null for reference types. /// The object to locate in the <see cref="T:System.Collections.Generic.List`1" />. The value can be null for reference types.
/// </param> /// </param>
public int IndexOf(T item) { public int IndexOf(T item) {
return Array.IndexOf(Items, item, 0, _size); return Array.IndexOf(Items, item, 0, size);
} }
/// <summary> /// <summary>
@ -194,17 +222,17 @@ namespace Spine {
/// . /// .
/// </exception> /// </exception>
public void Insert(int index, T item) { public void Insert(int index, T item) {
if ((uint) index > (uint) _size) { if ((uint) index > (uint) size) {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
if (_size == Items.Length) { if (size == Items.Length) {
EnsureCapacity(_size + 1); EnsureCapacity(size + 1);
} }
if (index < _size) { if (index < size) {
Array.Copy(Items, index, Items, index + 1, _size - index); Array.Copy(Items, index, Items, index + 1, size - index);
} }
Items[index] = item; Items[index] = item;
++_size; ++size;
} }
/// <summary> /// <summary>
@ -239,14 +267,14 @@ namespace Spine {
/// . /// .
/// </exception> /// </exception>
public void RemoveAt(int index) { public void RemoveAt(int index) {
if ((uint) index >= (uint) _size) { if ((uint) index >= (uint) size) {
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
--_size; --size;
if (index < _size) { if (index < size) {
Array.Copy(Items, index + 1, Items, index, _size - index); Array.Copy(Items, index + 1, Items, index, size - index);
} }
Items[_size] = default (T); Items[size] = default (T);
} }
/// <summary> /// <summary>
@ -309,7 +337,7 @@ namespace Spine {
/// to the end of the destination <paramref name="array" />. /// to the end of the destination <paramref name="array" />.
/// </exception> /// </exception>
public void CopyTo(int index, T[] array, int arrayIndex, int count) { public void CopyTo(int index, T[] array, int arrayIndex, int count) {
if (_size - index < count) { if (size - index < count) {
throw new ArgumentException("Invalid length"); throw new ArgumentException("Invalid length");
} }
Array.Copy(Items, index, array, arrayIndex, count); Array.Copy(Items, index, array, arrayIndex, count);
@ -349,12 +377,12 @@ namespace Spine {
if (index < 0 || count < 0) { if (index < 0 || count < 0) {
throw new ArgumentOutOfRangeException("index || count"); throw new ArgumentOutOfRangeException("index || count");
} }
if (_size - index < count) { if (size - index < count) {
throw new ArgumentException("Invalid length"); throw new ArgumentException("Invalid length");
} }
var list = new ExposedList<T>(count); var list = new ExposedList<T>(count);
Array.Copy(Items, index, list.Items, 0, count); Array.Copy(Items, index, list.Items, 0, count);
list._size = count; list.size = count;
return list; return list;
} }
@ -381,10 +409,10 @@ namespace Spine {
/// . /// .
/// </exception> /// </exception>
public int IndexOf(T item, int index) { public int IndexOf(T item, int index) {
if (index > _size) { if (index > size) {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
return Array.IndexOf(Items, item, index, _size - index); return Array.IndexOf(Items, item, index, size - index);
} }
/// <summary> /// <summary>
@ -420,10 +448,10 @@ namespace Spine {
/// . /// .
/// </exception> /// </exception>
public int IndexOf(T item, int index, int count) { public int IndexOf(T item, int index, int count) {
if (index > _size) { if (index > size) {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
if (count < 0 || index > _size - count) { if (count < 0 || index > size - count) {
throw new ArgumentOutOfRangeException("count"); throw new ArgumentOutOfRangeException("count");
} }
return Array.IndexOf(Items, item, index, count); return Array.IndexOf(Items, item, index, count);
@ -445,7 +473,7 @@ namespace Spine {
/// The object to locate in the <see cref="T:System.Collections.Generic.List`1" />. The value can be null for reference types. /// The object to locate in the <see cref="T:System.Collections.Generic.List`1" />. The value can be null for reference types.
/// </param> /// </param>
public int LastIndexOf(T item) { public int LastIndexOf(T item) {
return LastIndexOf(item, _size - 1, _size); return LastIndexOf(item, size - 1, size);
} }
/// <summary> /// <summary>
@ -471,7 +499,7 @@ namespace Spine {
/// . /// .
/// </exception> /// </exception>
public int LastIndexOf(T item, int index) { public int LastIndexOf(T item, int index) {
if (index >= _size) { if (index >= size) {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
return LastIndexOf(item, index, index + 1); return LastIndexOf(item, index, index + 1);
@ -510,13 +538,13 @@ namespace Spine {
/// . /// .
/// </exception> /// </exception>
public int LastIndexOf(T item, int index, int count) { public int LastIndexOf(T item, int index, int count) {
if (_size == 0) { if (size == 0) {
return -1; return -1;
} }
if (index < 0 || count < 0) { if (index < 0 || count < 0) {
throw new ArgumentOutOfRangeException("index || count"); throw new ArgumentOutOfRangeException("index || count");
} }
if (index >= _size || count > index + 1) { if (index >= size || count > index + 1) {
throw new ArgumentOutOfRangeException("size || count"); throw new ArgumentOutOfRangeException("size || count");
} }
return Array.LastIndexOf(Items, item, index, count); return Array.LastIndexOf(Items, item, index, count);
@ -540,27 +568,35 @@ namespace Spine {
if (index < 0 || count < 0) { if (index < 0 || count < 0) {
throw new ArgumentOutOfRangeException("index || count"); throw new ArgumentOutOfRangeException("index || count");
} }
if (_size - index < count) { if (size - index < count) {
throw new ArgumentException("Invalid length"); throw new ArgumentException("Invalid length");
} }
if (count <= 0) { if (count <= 0) {
return; return;
} }
_size -= count; size -= count;
if (index < _size) { if (index < size) {
Array.Copy(Items, index + count, Items, index, _size - index); Array.Copy(Items, index + count, Items, index, size - index);
}
Array.Clear(Items, size, count);
}
public void TrimExcess() {
int threshold = (int)(((double) Items.Length) * 0.9);
if( size < threshold ) {
Capacity = size;
} }
Array.Clear(Items, _size, count);
} }
//public void Sort(Comparison<T> comparison) //public void Sort(Comparison<T> comparison)
//{ //{
// if (comparison == null) // if (comparison == null)
// ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); // ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
// if (this._size <= 0) // if (this.size <= 0)
// return; // return;
// Array.Sort<T>(this._items, 0, this._size, (IComparer<T>) new Array.FunctorComparer<T>(comparison)); // Array.Sort<T>(this._items, 0, this.size, (IComparer<T>) new Array.FunctorComparer<T>(comparison));
//} //}
/// <summary> /// <summary>
/// Sorts the elements in the entire <see cref="T:System.Collections.Generic.List`1" /> using the specified /// Sorts the elements in the entire <see cref="T:System.Collections.Generic.List`1" /> using the specified
/// <see /// <see
@ -586,8 +622,8 @@ namespace Spine {
/// An array containing copies of the elements of the <see cref="T:System.Collections.Generic.List`1" />. /// An array containing copies of the elements of the <see cref="T:System.Collections.Generic.List`1" />.
/// </returns> /// </returns>
public T[] ToArray() { public T[] ToArray() {
var objArray = new T[_size]; var objArray = new T[size];
Array.Copy(Items, 0, objArray, 0, _size); Array.Copy(Items, 0, objArray, 0, size);
return objArray; return objArray;
} }
@ -600,7 +636,6 @@ namespace Spine {
return new Enumerator(this); return new Enumerator(this);
} }
/// <internalonly/>
IEnumerator<T> IEnumerable<T>.GetEnumerator() { IEnumerator<T> IEnumerable<T>.GetEnumerator() {
return new Enumerator(this); return new Enumerator(this);
} }
@ -612,25 +647,25 @@ namespace Spine {
[Serializable()] [Serializable()]
public struct Enumerator : IEnumerator<T>, System.Collections.IEnumerator public struct Enumerator : IEnumerator<T>, System.Collections.IEnumerator
{ {
private readonly ExposedList<T> _list; private readonly ExposedList<T> list;
private int _index; private int index;
private T _current; private T current;
internal Enumerator(ExposedList<T> list) { internal Enumerator(ExposedList<T> list) {
_list = list; this.list = list;
_index = 0; index = 0;
_current = default(T); current = default(T);
} }
public void Dispose() { public void Dispose() {
} }
public bool MoveNext() { public bool MoveNext() {
ExposedList<T> localList = _list; ExposedList<T> localList = list;
if (((uint)_index < (uint)localList._size)) { if (((uint)index < (uint)localList.size)) {
_current = localList.Items[_index]; current = localList.Items[index];
_index++; index++;
return true; return true;
} }
return MoveNextRare(); return MoveNextRare();
@ -638,28 +673,28 @@ namespace Spine {
private bool MoveNextRare() private bool MoveNextRare()
{ {
_index = _list._size + 1; index = list.size + 1;
_current = default(T); current = default(T);
return false; return false;
} }
public T Current { public T Current {
get { get {
return _current; return current;
} }
} }
Object System.Collections.IEnumerator.Current { Object System.Collections.IEnumerator.Current {
get { get {
if( _index == 0 || _index == _list._size + 1) if( index == 0 || index == list.size + 1)
throw new InvalidOperationException(); throw new InvalidOperationException();
return Current; return Current;
} }
} }
void System.Collections.IEnumerator.Reset() { void System.Collections.IEnumerator.Reset() {
_index = 0; index = 0;
_current = default(T); current = default(T);
} }
} }

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 540cf6a03c85e284e83831880e3f25a8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -34,25 +34,25 @@ using System.Collections.Generic;
namespace Spine { namespace Spine {
public class SkeletonData { public class SkeletonData {
internal String name; internal String name;
internal List<BoneData> bones = new List<BoneData>(); internal ExposedList<BoneData> bones = new ExposedList<BoneData>();
internal List<SlotData> slots = new List<SlotData>(); internal ExposedList<SlotData> slots = new ExposedList<SlotData>();
internal List<Skin> skins = new List<Skin>(); internal ExposedList<Skin> skins = new ExposedList<Skin>();
internal Skin defaultSkin; internal Skin defaultSkin;
internal List<EventData> events = new List<EventData>(); internal ExposedList<EventData> events = new ExposedList<EventData>();
internal List<Animation> animations = new List<Animation>(); internal ExposedList<Animation> animations = new ExposedList<Animation>();
internal List<IkConstraintData> ikConstraints = new List<IkConstraintData>(); internal ExposedList<IkConstraintData> ikConstraints = new ExposedList<IkConstraintData>();
internal float width, height; internal float width, height;
internal String version, hash; internal String version, hash;
public String Name { get { return name; } set { name = value; } } public String Name { get { return name; } set { name = value; } }
public List<BoneData> Bones { get { return bones; } } // Ordered parents first. public ExposedList<BoneData> Bones { get { return bones; } } // Ordered parents first.
public List<SlotData> Slots { get { return slots; } } // Setup pose draw order. public ExposedList<SlotData> Slots { get { return slots; } } // Setup pose draw order.
public List<Skin> Skins { get { return skins; } set { skins = value; } } public ExposedList<Skin> Skins { get { return skins; } set { skins = value; } }
/// <summary>May be null.</summary> /// <summary>May be null.</summary>
public Skin DefaultSkin { get { return defaultSkin; } set { defaultSkin = value; } } public Skin DefaultSkin { get { return defaultSkin; } set { defaultSkin = value; } }
public List<EventData> Events { get { return events; } set { events = value; } } public ExposedList<EventData> Events { get { return events; } set { events = value; } }
public List<Animation> Animations { get { return animations; } set { animations = value; } } public ExposedList<Animation> Animations { get { return animations; } set { animations = value; } }
public List<IkConstraintData> IkConstraints { get { return ikConstraints; } set { ikConstraints = value; } } public ExposedList<IkConstraintData> IkConstraints { get { return ikConstraints; } set { ikConstraints = value; } }
public float Width { get { return width; } set { width = value; } } public float Width { get { return width; } set { width = value; } }
public float Height { get { return height; } set { height = value; } } public float Height { get { return height; } set { height = value; } }
/// <summary>The Spine version used to export this data.</summary> /// <summary>The Spine version used to export this data.</summary>
@ -64,9 +64,9 @@ namespace Spine {
/// <returns>May be null.</returns> /// <returns>May be null.</returns>
public BoneData FindBone (String boneName) { public BoneData FindBone (String boneName) {
if (boneName == null) throw new ArgumentNullException("boneName cannot be null."); if (boneName == null) throw new ArgumentNullException("boneName cannot be null.");
List<BoneData> bones = this.bones; ExposedList<BoneData> bones = this.bones;
for (int i = 0, n = bones.Count; i < n; i++) { for (int i = 0, n = bones.Count; i < n; i++) {
BoneData bone = bones[i]; BoneData bone = bones.Items[i];
if (bone.name == boneName) return bone; if (bone.name == boneName) return bone;
} }
return null; return null;
@ -75,9 +75,9 @@ namespace Spine {
/// <returns>-1 if the bone was not found.</returns> /// <returns>-1 if the bone was not found.</returns>
public int FindBoneIndex (String boneName) { public int FindBoneIndex (String boneName) {
if (boneName == null) throw new ArgumentNullException("boneName cannot be null."); if (boneName == null) throw new ArgumentNullException("boneName cannot be null.");
List<BoneData> bones = this.bones; ExposedList<BoneData> bones = this.bones;
for (int i = 0, n = bones.Count; i < n; i++) for (int i = 0, n = bones.Count; i < n; i++)
if (bones[i].name == boneName) return i; if (bones.Items[i].name == boneName) return i;
return -1; return -1;
} }
@ -86,9 +86,9 @@ namespace Spine {
/// <returns>May be null.</returns> /// <returns>May be null.</returns>
public SlotData FindSlot (String slotName) { public SlotData FindSlot (String slotName) {
if (slotName == null) throw new ArgumentNullException("slotName cannot be null."); if (slotName == null) throw new ArgumentNullException("slotName cannot be null.");
List<SlotData> slots = this.slots; ExposedList<SlotData> slots = this.slots;
for (int i = 0, n = slots.Count; i < n; i++) { for (int i = 0, n = slots.Count; i < n; i++) {
SlotData slot = slots[i]; SlotData slot = slots.Items[i];
if (slot.name == slotName) return slot; if (slot.name == slotName) return slot;
} }
return null; return null;
@ -97,9 +97,9 @@ namespace Spine {
/// <returns>-1 if the bone was not found.</returns> /// <returns>-1 if the bone was not found.</returns>
public int FindSlotIndex (String slotName) { public int FindSlotIndex (String slotName) {
if (slotName == null) throw new ArgumentNullException("slotName cannot be null."); if (slotName == null) throw new ArgumentNullException("slotName cannot be null.");
List<SlotData> slots = this.slots; ExposedList<SlotData> slots = this.slots;
for (int i = 0, n = slots.Count; i < n; i++) for (int i = 0, n = slots.Count; i < n; i++)
if (slots[i].name == slotName) return i; if (slots.Items[i].name == slotName) return i;
return -1; return -1;
} }
@ -128,9 +128,9 @@ namespace Spine {
/// <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.");
List<Animation> animations = this.animations; ExposedList<Animation> animations = this.animations;
for (int i = 0, n = animations.Count; i < n; i++) { for (int i = 0, n = animations.Count; i < n; i++) {
Animation animation = animations[i]; Animation animation = animations.Items[i];
if (animation.name == animationName) return animation; if (animation.name == animationName) return animation;
} }
return null; return null;
@ -141,9 +141,9 @@ namespace Spine {
/// <returns>May be null.</returns> /// <returns>May be null.</returns>
public IkConstraintData FindIkConstraint (String ikConstraintName) { public IkConstraintData FindIkConstraint (String ikConstraintName) {
if (ikConstraintName == null) throw new ArgumentNullException("ikConstraintName cannot be null."); if (ikConstraintName == null) throw new ArgumentNullException("ikConstraintName cannot be null.");
List<IkConstraintData> ikConstraints = this.ikConstraints; ExposedList<IkConstraintData> ikConstraints = this.ikConstraints;
for (int i = 0, n = ikConstraints.Count; i < n; i++) { for (int i = 0, n = ikConstraints.Count; i < n; i++) {
IkConstraintData ikConstraint = ikConstraints[i]; IkConstraintData ikConstraint = ikConstraints.Items[i];
if (ikConstraint.name == ikConstraintName) return ikConstraint; if (ikConstraint.name == ikConstraintName) return ikConstraint;
} }
return null; return null;

View File

@ -376,7 +376,7 @@ namespace Spine {
} }
private void ReadAnimation (String name, Dictionary<String, Object> map, SkeletonData skeletonData) { private void ReadAnimation (String name, Dictionary<String, Object> map, SkeletonData skeletonData) {
var timelines = new List<Timeline>(); var timelines = new ExposedList<Timeline>();
float duration = 0; float duration = 0;
float scale = Scale; float scale = Scale;

View File

@ -80,7 +80,7 @@ public class BoneFollowerInspector : Editor {
bones[0] = "<None>"; bones[0] = "<None>";
for (int i = 0; i < bones.Length - 1; i++) for (int i = 0; i < bones.Length - 1; i++)
bones[i + 1] = component.skeletonRenderer.skeleton.Data.Bones[i].Name; bones[i + 1] = component.skeletonRenderer.skeleton.Data.Bones.Items[i].Name;
Array.Sort<String>(bones); Array.Sort<String>(bones);
int boneIndex = Math.Max(0, Array.IndexOf(bones, boneName.stringValue)); int boneIndex = Math.Max(0, Array.IndexOf(bones, boneName.stringValue));

View File

@ -74,7 +74,7 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
animations[0] = "<None>"; animations[0] = "<None>";
int animationIndex = 0; int animationIndex = 0;
for (int i = 0; i < animations.Length - 1; i++) { for (int i = 0; i < animations.Length - 1; i++) {
String name = component.skeleton.Data.Animations[i].Name; String name = component.skeleton.Data.Animations.Items[i].Name;
animations[i + 1] = name; animations[i + 1] = name;
if (name == animationName.stringValue) if (name == animationName.stringValue)
animationIndex = i + 1; animationIndex = i + 1;

View File

@ -76,7 +76,7 @@ public static class SkeletonBaker {
/// </summary> /// </summary>
const float bakeIncrement = 1 / 60f; const float bakeIncrement = 1 / 60f;
public static void BakeToPrefab (SkeletonDataAsset skeletonDataAsset, List<Skin> skins, string outputPath = "", bool bakeAnimations = true, bool bakeIK = true, SendMessageOptions eventOptions = SendMessageOptions.DontRequireReceiver) { public static void BakeToPrefab (SkeletonDataAsset skeletonDataAsset, ExposedList<Skin> skins, string outputPath = "", bool bakeAnimations = true, bool bakeIK = true, SendMessageOptions eventOptions = SendMessageOptions.DontRequireReceiver) {
if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(true) == null) { if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(true) == null) {
Debug.LogError("Could not export Spine Skeleton because SkeletonDataAsset is null or invalid!"); Debug.LogError("Could not export Spine Skeleton because SkeletonDataAsset is null or invalid!");
return; return;
@ -135,7 +135,7 @@ public static class SkeletonBaker {
for (int s = 0; s < skeletonData.Slots.Count; s++) { for (int s = 0; s < skeletonData.Slots.Count; s++) {
List<string> attachmentNames = new List<string>(); List<string> attachmentNames = new List<string>();
for (int i = 0; i < skinCount; i++) { for (int i = 0; i < skinCount; i++) {
var skin = skins[i]; var skin = skins.Items[i];
List<string> temp = new List<string>(); List<string> temp = new List<string>();
skin.FindNamesForSlot(s, temp); skin.FindNamesForSlot(s, temp);
foreach (string str in temp) { foreach (string str in temp) {
@ -216,7 +216,7 @@ public static class SkeletonBaker {
//create bones //create bones
for (int i = 0; i < skeletonData.Bones.Count; i++) { for (int i = 0; i < skeletonData.Bones.Count; i++) {
var boneData = skeletonData.Bones[i]; var boneData = skeletonData.Bones.Items[i];
Transform boneTransform = new GameObject(boneData.Name).transform; Transform boneTransform = new GameObject(boneData.Name).transform;
boneTransform.parent = prefabRoot.transform; boneTransform.parent = prefabRoot.transform;
boneTable.Add(boneTransform.name, boneTransform); boneTable.Add(boneTransform.name, boneTransform);
@ -225,7 +225,7 @@ public static class SkeletonBaker {
for (int i = 0; i < skeletonData.Bones.Count; i++) { for (int i = 0; i < skeletonData.Bones.Count; i++) {
var boneData = skeletonData.Bones[i]; var boneData = skeletonData.Bones.Items[i];
Transform boneTransform = boneTable[boneData.Name]; Transform boneTransform = boneTable[boneData.Name];
Transform parentTransform = null; Transform parentTransform = null;
if (i > 0) if (i > 0)
@ -246,7 +246,7 @@ public static class SkeletonBaker {
//create slots and attachments //create slots and attachments
for (int i = 0; i < skeletonData.Slots.Count; i++) { for (int i = 0; i < skeletonData.Slots.Count; i++) {
var slotData = skeletonData.Slots[i]; var slotData = skeletonData.Slots.Items[i];
Transform slotTransform = new GameObject(slotData.Name).transform; Transform slotTransform = new GameObject(slotData.Name).transform;
slotTransform.parent = prefabRoot.transform; slotTransform.parent = prefabRoot.transform;
slotTable.Add(slotData.Name, slotTransform); slotTable.Add(slotData.Name, slotTransform);
@ -807,26 +807,26 @@ public static class SkeletonBaker {
List<int> ignoreRotateTimelineIndexes = new List<int>(); List<int> ignoreRotateTimelineIndexes = new List<int>();
//if (bakeIK) { if (bakeIK) {
// foreach (IkConstraint i in skeleton.IkConstraints) { foreach (IkConstraint i in skeleton.IkConstraints) {
// foreach (Bone b in i.Bones) { foreach (Bone b in i.Bones) {
// int index = skeleton.FindBoneIndex(b.Data.Name); int index = skeleton.FindBoneIndex(b.Data.Name);
// ignoreRotateTimelineIndexes.Add(index); ignoreRotateTimelineIndexes.Add(index);
// BakeBone(b, animation, clip); BakeBone(b, animation, clip);
// } }
// } }
//} }
//foreach (Bone b in skeleton.Bones) { foreach (Bone b in skeleton.Bones) {
// if (b.Data.InheritRotation == false) { if (b.Data.InheritRotation == false) {
// int index = skeleton.FindBoneIndex(b.Data.Name); int index = skeleton.FindBoneIndex(b.Data.Name);
// if (ignoreRotateTimelineIndexes.Contains(index) == false) { if (ignoreRotateTimelineIndexes.Contains(index) == false) {
// ignoreRotateTimelineIndexes.Add(index); ignoreRotateTimelineIndexes.Add(index);
// BakeBone(b, animation, clip); BakeBone(b, animation, clip);
// } }
// } }
//} }
foreach (Timeline t in timelines) { foreach (Timeline t in timelines) {
skeleton.SetToSetupPose(); skeleton.SetToSetupPose();
@ -1061,7 +1061,7 @@ public static class SkeletonBaker {
} }
static void ParseTranslateTimeline (Skeleton skeleton, TranslateTimeline timeline, AnimationClip clip) { static void ParseTranslateTimeline (Skeleton skeleton, TranslateTimeline timeline, AnimationClip clip) {
var boneData = skeleton.Data.Bones[timeline.BoneIndex]; var boneData = skeleton.Data.Bones.Items[timeline.BoneIndex];
var bone = skeleton.Bones.Items[timeline.BoneIndex]; var bone = skeleton.Bones.Items[timeline.BoneIndex];
AnimationCurve xCurve = new AnimationCurve(); AnimationCurve xCurve = new AnimationCurve();
@ -1207,7 +1207,7 @@ public static class SkeletonBaker {
} }
static void ParseScaleTimeline (Skeleton skeleton, ScaleTimeline timeline, AnimationClip clip) { static void ParseScaleTimeline (Skeleton skeleton, ScaleTimeline timeline, AnimationClip clip) {
var boneData = skeleton.Data.Bones[timeline.BoneIndex]; var boneData = skeleton.Data.Bones.Items[timeline.BoneIndex];
var bone = skeleton.Bones.Items[timeline.BoneIndex]; var bone = skeleton.Bones.Items[timeline.BoneIndex];
AnimationCurve xCurve = new AnimationCurve(); AnimationCurve xCurve = new AnimationCurve();
@ -1340,7 +1340,7 @@ public static class SkeletonBaker {
} }
static void ParseRotateTimeline (Skeleton skeleton, RotateTimeline timeline, AnimationClip clip) { static void ParseRotateTimeline (Skeleton skeleton, RotateTimeline timeline, AnimationClip clip) {
var boneData = skeleton.Data.Bones[timeline.BoneIndex]; var boneData = skeleton.Data.Bones.Items[timeline.BoneIndex];
var bone = skeleton.Bones.Items[timeline.BoneIndex]; var bone = skeleton.Bones.Items[timeline.BoneIndex];
AnimationCurve curve = new AnimationCurve(); AnimationCurve curve = new AnimationCurve();

View File

@ -186,7 +186,7 @@ public class SkeletonDataAssetInspector : Editor {
Skin bakeSkin = m_skeletonAnimation.skeleton.Skin; Skin bakeSkin = m_skeletonAnimation.skeleton.Skin;
if (bakeSkin == null) { if (bakeSkin == null) {
skinName = "Default"; skinName = "Default";
bakeSkin = m_skeletonData.Skins[0]; bakeSkin = m_skeletonData.Skins.Items[0];
} else } else
skinName = m_skeletonAnimation.skeleton.Skin.Name; skinName = m_skeletonAnimation.skeleton.Skin.Name;
@ -195,7 +195,7 @@ public class SkeletonDataAssetInspector : Editor {
try { try {
GUILayout.BeginVertical(); GUILayout.BeginVertical();
if (GUILayout.Button(new GUIContent("Bake " + skinName, SpineEditorUtilities.Icons.unityIcon), GUILayout.Height(32), GUILayout.Width(250))) if (GUILayout.Button(new GUIContent("Bake " + skinName, SpineEditorUtilities.Icons.unityIcon), GUILayout.Height(32), GUILayout.Width(250)))
SkeletonBaker.BakeToPrefab(m_skeletonDataAsset, new List<Skin>(new Skin[] { bakeSkin }), "", bakeAnimations, bakeIK, bakeEventOptions); SkeletonBaker.BakeToPrefab(m_skeletonDataAsset, new ExposedList<Skin>(new Skin[] { bakeSkin }), "", bakeAnimations, bakeIK, bakeEventOptions);
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.Label(new GUIContent("Skins", SpineEditorUtilities.Icons.skinsRoot), GUILayout.Width(50)); GUILayout.Label(new GUIContent("Skins", SpineEditorUtilities.Icons.skinsRoot), GUILayout.Width(50));
@ -259,7 +259,7 @@ public class SkeletonDataAssetInspector : Editor {
// Animation names // Animation names
String[] animations = new String[m_skeletonData.Animations.Count]; String[] animations = new String[m_skeletonData.Animations.Count];
for (int i = 0; i < animations.Length; i++) for (int i = 0; i < animations.Length; i++)
animations[i] = m_skeletonData.Animations[i].Name; animations[i] = m_skeletonData.Animations.Items[i].Name;
for (int i = 0; i < fromAnimation.arraySize; i++) { for (int i = 0; i < fromAnimation.arraySize; i++) {
SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i);
@ -350,7 +350,7 @@ public class SkeletonDataAssetInspector : Editor {
List<Attachment> slotAttachments = new List<Attachment>(); List<Attachment> slotAttachments = new List<Attachment>();
List<string> slotAttachmentNames = new List<string>(); List<string> slotAttachmentNames = new List<string>();
List<string> defaultSkinAttachmentNames = new List<string>(); List<string> defaultSkinAttachmentNames = new List<string>();
var defaultSkin = m_skeletonData.Skins[0]; var defaultSkin = m_skeletonData.Skins.Items[0];
Skin skin = m_skeletonAnimation.skeleton.Skin; Skin skin = m_skeletonAnimation.skeleton.Skin;
if (skin == null) { if (skin == null) {
skin = defaultSkin; skin = defaultSkin;

View File

@ -78,7 +78,7 @@ public class SkeletonRendererInspector : Editor {
String[] skins = new String[component.skeleton.Data.Skins.Count]; String[] skins = new String[component.skeleton.Data.Skins.Count];
int skinIndex = 0; int skinIndex = 0;
for (int i = 0; i < skins.Length; i++) { for (int i = 0; i < skins.Length; i++) {
String name = component.skeleton.Data.Skins[i].Name; String name = component.skeleton.Data.Skins.Items[i].Name;
skins[i] = name; skins[i] = name;
if (name == initialSkinName.stringValue) if (name == initialSkinName.stringValue)
skinIndex = i; skinIndex = i;

View File

@ -113,7 +113,7 @@ public class SpineSlotDrawer : PropertyDrawer {
menu.AddSeparator(""); menu.AddSeparator("");
for (int i = 0; i < data.Slots.Count; i++) { for (int i = 0; i < data.Slots.Count; i++) {
string name = data.Slots[i].Name; string name = data.Slots.Items[i].Name;
if (name.StartsWith(attrib.startsWith)) if (name.StartsWith(attrib.startsWith))
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
} }
@ -191,7 +191,7 @@ public class SpineSkinDrawer : PropertyDrawer {
menu.AddSeparator(""); menu.AddSeparator("");
for (int i = 0; i < data.Skins.Count; i++) { for (int i = 0; i < data.Skins.Count; i++) {
string name = data.Skins[i].Name; string name = data.Skins.Items[i].Name;
if (name.StartsWith(attrib.startsWith)) if (name.StartsWith(attrib.startsWith))
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
} }
@ -331,7 +331,7 @@ public class SpineAnimationDrawer : PropertyDrawer {
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations; var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
for (int i = 0; i < animations.Count; i++) { for (int i = 0; i < animations.Count; i++) {
string name = animations[i].Name; string name = animations.Items[i].Name;
if (name.StartsWith(attrib.startsWith)) if (name.StartsWith(attrib.startsWith))
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
} }
@ -417,7 +417,7 @@ public class SpineAttachmentDrawer : PropertyDrawer {
if (skeletonRenderer.skeleton.Skin != null) { if (skeletonRenderer.skeleton.Skin != null) {
validSkins.Add(skeletonRenderer.skeleton.Skin); validSkins.Add(skeletonRenderer.skeleton.Skin);
} else { } else {
validSkins.Add(data.Skins[0]); validSkins.Add(data.Skins.Items[0]);
} }
} else { } else {
foreach (Skin skin in data.Skins) { foreach (Skin skin in data.Skins) {
@ -441,7 +441,7 @@ public class SpineAttachmentDrawer : PropertyDrawer {
menu.AddItem(new GUIContent("Null"), property.stringValue == "", HandleSelect, new SpineDrawerValuePair("", property)); menu.AddItem(new GUIContent("Null"), property.stringValue == "", HandleSelect, new SpineDrawerValuePair("", property));
menu.AddSeparator(""); menu.AddSeparator("");
Skin defaultSkin = data.Skins[0]; Skin defaultSkin = data.Skins.Items[0];
SerializedProperty slotProperty = property.serializedObject.FindProperty(attrib.slotField); SerializedProperty slotProperty = property.serializedObject.FindProperty(attrib.slotField);
string slotMatch = ""; string slotMatch = "";
@ -458,7 +458,7 @@ public class SpineAttachmentDrawer : PropertyDrawer {
prefix = skinPrefix; prefix = skinPrefix;
for (int i = 0; i < data.Slots.Count; i++) { for (int i = 0; i < data.Slots.Count; i++) {
if (slotMatch.Length > 0 && data.Slots[i].Name.ToLower().Contains(slotMatch) == false) if (slotMatch.Length > 0 && data.Slots.Items[i].Name.ToLower().Contains(slotMatch) == false)
continue; continue;
attachmentNames.Clear(); attachmentNames.Clear();
@ -474,11 +474,11 @@ public class SpineAttachmentDrawer : PropertyDrawer {
for (int a = 0; a < attachmentNames.Count; a++) { for (int a = 0; a < attachmentNames.Count; a++) {
string attachmentPath = attachmentNames[a]; string attachmentPath = attachmentNames[a];
string menuPath = prefix + data.Slots[i].Name + "/" + attachmentPath; string menuPath = prefix + data.Slots.Items[i].Name + "/" + attachmentPath;
string name = attachmentNames[a]; string name = attachmentNames[a];
if (attrib.returnAttachmentPath) if (attrib.returnAttachmentPath)
name = skin.Name + "/" + data.Slots[i].Name + "/" + attachmentPath; name = skin.Name + "/" + data.Slots.Items[i].Name + "/" + attachmentPath;
if (attrib.placeholdersOnly && placeholderNames.Contains(attachmentPath) == false) { if (attrib.placeholdersOnly && placeholderNames.Contains(attachmentPath) == false) {
menu.AddDisabledItem(new GUIContent(menuPath)); menu.AddDisabledItem(new GUIContent(menuPath));
@ -565,7 +565,7 @@ public class SpineBoneDrawer : PropertyDrawer {
menu.AddSeparator(""); menu.AddSeparator("");
for (int i = 0; i < data.Bones.Count; i++) { for (int i = 0; i < data.Bones.Count; i++) {
string name = data.Bones[i].Name; string name = data.Bones.Items[i].Name;
if (name.StartsWith(attrib.startsWith)) if (name.StartsWith(attrib.startsWith))
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property)); menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
} }

View File

@ -779,7 +779,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
skin = data.DefaultSkin; skin = data.DefaultSkin;
if (skin == null) if (skin == null)
skin = data.Skins[0]; skin = data.Skins.Items[0];
anim.Reset(); anim.Reset();
@ -865,7 +865,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
skin = data.DefaultSkin; skin = data.DefaultSkin;
if (skin == null) if (skin == null)
skin = data.Skins[0]; skin = data.Skins.Items[0];
anim.Reset(); anim.Reset();

View File

@ -190,19 +190,21 @@ public class SkeletonRenderer : MonoBehaviour {
} else { } else {
if (!renderMeshes) if (!renderMeshes)
continue; continue;
if (attachment is MeshAttachment) { MeshAttachment meshAttachment = attachment as MeshAttachment;
MeshAttachment meshAttachment = (MeshAttachment)attachment; if (meshAttachment != null) {
rendererObject = meshAttachment.RendererObject; rendererObject = meshAttachment.RendererObject;
attachmentVertexCount = meshAttachment.vertices.Length >> 1; attachmentVertexCount = meshAttachment.vertices.Length >> 1;
attachmentTriangleCount = meshAttachment.triangles.Length; attachmentTriangleCount = meshAttachment.triangles.Length;
} else if (attachment is SkinnedMeshAttachment) { } else {
SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment; SkinnedMeshAttachment skinnedMeshAttachment = attachment as SkinnedMeshAttachment;
rendererObject = meshAttachment.RendererObject; if (skinnedMeshAttachment != null) {
attachmentVertexCount = meshAttachment.uvs.Length >> 1; rendererObject = skinnedMeshAttachment.RendererObject;
attachmentTriangleCount = meshAttachment.triangles.Length; attachmentVertexCount = skinnedMeshAttachment.uvs.Length >> 1;
attachmentTriangleCount = skinnedMeshAttachment.triangles.Length;
} else } else
continue; continue;
} }
}
// Populate submesh when material changes. // Populate submesh when material changes.
Material material = (Material)((AtlasRegion)rendererObject).page.rendererObject; Material material = (Material)((AtlasRegion)rendererObject).page.rendererObject;