Hello!
First question here:)
I’m trying to create a list of prefabs with an enum as the index so that i can easily and quickly instantiate these prefabs from code. The list will be quite long if i manage, i want to put every game object there. The intended use would be somehting like this:
public List<GameObject> myPrefabs = new List<GameObject>();
public GameObject CreateGraphic(Graphic aGraphic)
{
GameObject newGraphic = GameObject)GameObject.Instantiate(myPrefabs[(int)aGraphic]);
return newGraphic;
}
EDIT: The question is, how do i fill the List with Prefabs in the enum order? I realize i that if i make the list public i can drag and drop prefabs in the editor, but that seems unreliable to me as there is no actual connection to the enum, just very careful and mistake prone ordering.
What i hope to find is a way to find these prefabs from code so i can enter them in the correct positions at Start(), using the enum as index.
Is this possible in any way? I tried with public dictionaries and hash tables, no luck. Am i going about this the wrong way?