I tried scripting it casually but gets an error Object reference not set to an instance of an Object C#.
im not sure if this helps but i think your trying to make an empty GameObject become say a map
void mapGen()
{
mapGenerator mapBuild = GetComponent<mapGenerator> () as mapGenerator;
mapBuild.generateMap();
}
so for the longest time i was getting the same null exception reference. the object in the scene the script is attached to i detached it and than in the void start i just loaded it like so.
void Start ()
{
gameObject.AddComponent<meshbuilder> ();
}
im by no means an expert but im pretty sure the null exception reference has to do with the fact your not pointing or making any reference to the actual gameobject in scene nor are you making a new one. so there is an error, not with the code itself but that to unity theres no object to change.
GameObject obj=(GameObject)Instantiate(prefab, “empty game object position”, Quaternion.identity);
if you want to spawn object as a child of empty gameobject then add this code :
obj.transform.parent=emptygameobject.transform;
make a transform for where you want them to spawn and drag the empty object into it