blob: 49ec53be9c172aa9c974417eae75a7fd29cefad8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using AdvancedInspector;
public class AIExample7_Collection : MonoBehaviour
{
// Any collection inspected by Advanced Inspector has the re-ordering controls.
public float[] myArray;
// The collection attribute gives you control on how the collection is displayed.
// Giving it a number forces the collection to be of a fixed size, it cannot grow or shrink.
[Collection(10)]
public int[] fixedArray;
// You can also turn off the sortable feature of an array, if for example item should be listed in a specific order.
[Collection(false)]
public bool[] unsortableArray;
// Collection can also be displayed 1 item at a time. You can use a drop down or buttons to navigate in it.
[Collection(Display = CollectionDisplay.DropDown)]
public List<bool> dropDownList;
// A collection size and index can also be bound to an enum type.
[Collection(typeof(MyCollectionEnum))]
public List<Vector3> enumBoundList;
// Very large collection get a scrolling system to not display them all at once.
[Collection(100, MaxDisplayedItems = 10)]
public string[] largeCollection;
// In some case, you may want a class to have a custom constructor.
// Usually, Unity is unable to invoke that constructor.
[Serializable]
public class CustomConstructor
{
public string value;
public CustomConstructor(string text)
{
value = text;
}
}
[Constructor("InvokeConstructor")]
public CustomConstructor[] constructors;
public CustomConstructor InvokeConstructor()
{
return new CustomConstructor("This was added in a constructor");
}
}
// When binding an enum with a collection, the values should be in a zero-based 1 increment order, similar to the index of the collection.
public enum MyCollectionEnum
{
ZeroValue = 0,
FirstValue = 1,
SecondValue = 2,
ThirdValue = 3,
ForthValue = 4
}
|