- Home /
How to deactivate or pause prefab array when pause button is pressed?
All the prefab i put it in spawner. How to deactivate or pause spawning all the prefabs array when the pause button is press?
Spawn script:
using UnityEngine; using System.Collections;
public class Spawnn : MonoBehaviour
{
public float spawnTime = 3f;
public float spawnDelay = 2f;
public GameObject[] mfood;
void Start ()
{
InvokeRepeating("Spawn", spawnDelay, spawnTime);
}
void Spawn ()
{
int mfoodIndex = Random.Range(0, mfood.Length);
Instantiate(mfood[mfoodIndex], transform.position, transform.rotation);
foreach(ParticleSystem p in GetComponentsInChildren<ParticleSystem>())
{
p.Play();
}
}
}
spawn.jpg
(20.0 kB)
Comment
Best Answer
Answer by abi-kr01 · May 11, 2015 at 06:49 AM
i think you can disable script that is responsible for spawning you can set a bullion say status;
now in
void Update()
{
if(!status)
{
transform.getcomponent<swanscript>().enabled=false;
`}
else
{
transform.getcomponent<swanscript>().enabled=true;
}
}
Your answer
Follow this Question
Related Questions
Save GameObject to file without Playerpref 2 Answers
How to spawn prefab only in allowed area? 0 Answers
Multiple Cars not working 1 Answer
creating animation made my each prefab spawn at same position 1 Answer
How to make an object/prefab choose between multiple given positions to spawn into? 1 Answer