I have this code which I use to instantiate a splurge of gas on a surface. It works the first time round, but when I toggle the gas OFF and then turn it ON again, I am no longer able to instantiate. Can anyone tell me why please?
createToggle = GUI.Toggle(Rect(115,390,110,30), createToggle, "GAS", "button");
creategas = createToggle;
if (creategas)
{
while (gasNumber <= 1.0) {
gasInstance = Instantiate(gasmaker);
gasNumber++;
}
}
else
{
var gas = GameObject.FindGameObjectsWithTag("gas");
for (var i in gas) {
Destroy(i);
}
}