Hello. I have a class in which I create an array of Serializable objects, however, I’m not sure how to go about spawning them in the game world. I tried to use a for loop but errors show up in the code preventing me from running it.
My serializable class:
[System.Serializable]
public class Presets
{
public string name;
public SetContainer[] Prest = new SetContainer[4];
}
[System.Serializable]
public class SetContainer
{
public GameObject gm;
public Vector3 position;
public Quaternion rotation;
public Vector3 scale;
}
My class where objects are spawned
public class SpawnObstacles : MonoBehaviour {
public Presets[] SETS;
private void SpawnThings(int index)//spawning the obstacles
{
Presets set = SETS[index];
for (int i = 0; i < set.length; i++)
{
Instantiate(set*);*
}
}
}