diff options
author | chai <chaifix@163.com> | 2020-10-15 07:04:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-10-15 07:04:38 +0800 |
commit | b71d5611db087772179505ed10c82ca958900df7 (patch) | |
tree | 5160f6af41d45529e435550879e0c87ea59c09a8 /Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample7_Collection.cs | |
parent | b1b14c45ce95dcf7b81867d68d6006345d98959e (diff) |
+advanced inspector
Diffstat (limited to 'Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample7_Collection.cs')
-rw-r--r-- | Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample7_Collection.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample7_Collection.cs b/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample7_Collection.cs new file mode 100644 index 00000000..49ec53be --- /dev/null +++ b/Assets/ThirdParty/AdvancedInspector/Examples/CSharp/AIExample7_Collection.cs @@ -0,0 +1,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 +}
\ No newline at end of file |