| | 1 | | using UnityEngine; |
| | 2 | | using System; |
| | 3 | | using System.Collections; |
| | 4 | | using System.Collections.Generic; |
| | 5 | |
|
| | 6 | | namespace ReorderableList |
| | 7 | | { |
| | 8 | |
|
| | 9 | | [Serializable] |
| | 10 | | public abstract class ReorderableArray<T> : ICloneable, IList<T>, ICollection<T>, IEnumerable<T> |
| | 11 | | { |
| | 12 | |
|
| | 13 | | [SerializeField] |
| 15089 | 14 | | private List<T> array = new List<T>(); |
| | 15 | |
|
| | 16 | | public ReorderableArray() |
| 30178 | 17 | | : this(0) { } |
| | 18 | |
|
| 45267 | 19 | | public ReorderableArray(int length) { array = new List<T>(length); } |
| | 20 | |
|
| 25660 | 21 | | public T this[int index] { get { return array[index]; } set { array[index] = value; } } |
| | 22 | |
|
| 0 | 23 | | public int Length { get { return array.Count; } } |
| | 24 | |
|
| 0 | 25 | | public bool IsReadOnly { get { return false; } } |
| | 26 | |
|
| 8 | 27 | | public int Count { get { return array.Count; } } |
| | 28 | |
|
| 0 | 29 | | public object Clone() { return new List<T>(array); } |
| | 30 | |
|
| | 31 | | public void CopyFrom(IEnumerable<T> value) |
| | 32 | | { |
| | 33 | |
|
| 0 | 34 | | array.Clear(); |
| 0 | 35 | | array.AddRange(value); |
| 0 | 36 | | } |
| | 37 | |
|
| 0 | 38 | | public bool Contains(T value) { return array.Contains(value); } |
| | 39 | |
|
| 0 | 40 | | public int IndexOf(T value) { return array.IndexOf(value); } |
| | 41 | |
|
| 0 | 42 | | public void Insert(int index, T item) { array.Insert(index, item); } |
| | 43 | |
|
| 0 | 44 | | public void RemoveAt(int index) { array.RemoveAt(index); } |
| | 45 | |
|
| 8 | 46 | | public void Add(T item) { array.Add(item); } |
| | 47 | |
|
| 2 | 48 | | public void Clear() { array.Clear(); } |
| | 49 | |
|
| 16 | 50 | | public void CopyTo(T[] array, int arrayIndex) { this.array.CopyTo(array, arrayIndex); } |
| | 51 | |
|
| 0 | 52 | | public bool Remove(T item) { return array.Remove(item); } |
| | 53 | |
|
| 0 | 54 | | public T[] ToArray() { return array.ToArray(); } |
| | 55 | |
|
| 2164 | 56 | | public IEnumerator<T> GetEnumerator() { return array.GetEnumerator(); } |
| | 57 | |
|
| 0 | 58 | | IEnumerator IEnumerable.GetEnumerator() { return array.GetEnumerator(); } |
| | 59 | | } |
| | 60 | | } |