Hello,
I’m looking for a way to have multiple objects in an arraylist. The idea is to have a GameObject, String and Integer all together in, for example, an array and put that array in a list.
While this is all possible (and I could even make a list in a list, or a custom object in the “parent” list) I haven’t found a way to let this show up in the inspector.
Following below is a little code snippet to make myself any more clear.
Does someone know a solution for this problem?
The reason I’m doing this (in case anyone is wondering) is for dynamic level generation (randomly generating prefabs in prefabs on certain points with a certain chance).
public List<List<object>> arrayList;
private List<object> miniList;
void initialise()
{
arrayList = new List<List<object>>();
//These have to be the 3 fields visible in the inspector
GameObject gameobject1 = new GameObject();
int value1 = 0;
string name1 = "";
//This would be the "Size" property of the list (in the inspector)
arrayList.Add(fillSmallList(gameobject1, value1, name1));
}
List<object> fillSmallList(GameObject go, int i, string s)
{
miniList = new List<object>();
miniList.Add(go);
miniList.Add(i);
miniList.Add(s);
return miniList;
}
//To further visuaise, I want to be able to see and modify the following in the inspector:
//ListEntry1: Gameobject1, Value1, String1
//ListEntry2: Gameobject2, Value2, String2
//ListEntry3: Gameobject3, Value3, String3
//etc...