I have created a public class array containing a GameObject, some integers, and some Strings…
[System.Serializable]
public class SpawnerObject
{
public GameObject Object;
public int Weight = 1;
public int WeightValue;
public string Name;
public string Tag;
public int TotalSpawned;
}
public SpawnerObject[] SpawnerObjects;
I also have a method that attempts to load child objects from a specified GameObject (PrefabsFolder) into this class array (see code below). The method is called from the associated editor code button and it is stepping through the ‘LoadPrefabsFolder’ code but not updating the class array completely…
public void LoadPrefabsFolder()
{
if (PrefabsFolder)
{
// Get count of children in prefab folder
int Prefabs = PrefabsFolder.transform.childCount;
// Update spawner objects array
SpawnerObject[] SpawnerObjects = new SpawnerObject[Prefabs];
// Add each prefab to the spawner objects array
for (int i = 0; i < Prefabs; i++)
{
Transform tObjects = PrefabsFolder.transform.GetChild(i);
GameObject oObject = tObjects.gameObject;
SpawnerObject Prefab = new SpawnerObject();
Prefab.Name = tObjects.name;
Prefab.Tag = tObjects.tag;
Prefab.Object = oObject;
Prefab.TotalSpawned = 0;
Prefab.Weight = 1;
Prefab.WeightValue = 1;
SpawnerObjects *= Prefab;*
}
}
}
Note that I have removed code that performs various checks (e.g. reports missing objects to the debug log) to simplify the code for you. Can someone tell me what I’m missing/doing wrong here?
ThanX - DJ