New to Unity, so be gentle. Started today.
I am putting together a very basic environment-builder. I have an interface up and running with panels and icons that I want to press to spawn different Prefabs. I’ve gotten my prefab to spawn via button press with this very basic script:
var instance : GameObject;
function Start () {
Instantiate(Resources.Load("Building_A", GameObject));
}
I’ve been hunting through Google, Unity documentation, and this site for a very simple way to stop Prefabs from instancing infinitely. I have seen some very confusing examples involving booleans, setting the max number of Prefabs to 1 and doing a check, cancel invoke, and a few others.
Several solutions simply say not to use use Function Update-(so it only spawns one instance) which I don’t believe I am using. Do I not have this running under Function Start as above?
Is there not a very simple way to do this? If you can spawn a prefab in one line of code is there not a way to cancel the instantiation as simply? Do you have to use Destroy or the like?
Bear in mind I have zero programming/scripting experience. RTFM responses are welcome provided someone can point me to where it explains this simply for a neophyte. I can’t seem to find a clear example with simple code like mine above.
Any help appreciated.