- Home /
 
How can I make multiple of entry for arraylist in inspector
How can I have a arraylist that has multiple of element list for inspector?
For example; Element 0 - Output - Target - Input - Parameter - Delay - Boolean Only Once
Any idea how can I achieve this via C#?
I thought about doing something like public Arraylist[][][][][][] Outputs = new Arraylist[output[]][target[]][input[]]... and so on?
Answer by Skibur · Aug 24, 2013 at 05:20 PM
Figure it out. Here's what I did to make it work for those who wanted to do something like this;
 public class Trigger : MonoBehaviour {
 
     [System.Serializable]
     public class Outputs {
         public enum Output : byte { OnStartTouch, OnStartTouchAll, OnEndTouch, OnEndTouchAll, OnTrigger }
         public Output output; 
         public GameObject Target;
         public enum Inputs : byte { Enabled, Disabled, SetParent, PlayAudio, EnableTrigger, DisableTrigger, SetCheckPoint }
         public Inputs input; 
         public string parameter;
         public float delay;
         public bool isFiredOnce;
     }
     public Outputs[] events;
 }
 
              You might want to look up what an ArrayList is - I'm not sure it does what you think it does.
It works for me. It shows in the inspector with a list of items I can add per each elements.
Here's what it looks like - 
No, I mean you're not actually using ArrayLists in your solution, but you should perhaps look them up, as they are quite handy in some circumstances, and I don't think they do what you thought they did.
Answer by Sisso · Aug 24, 2013 at 05:22 PM
Try to encapsulate each array in a proper class. This is javascript, but i think that is the same with c#.
 class Data1 {
   var array: Data2[];
 }
 
 class Data2 {
   var array: String[];
 }
 
 var array: Data1[];
 
              Your answer