Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- import System.Collections.Generic;
- var sphere : GameObject;
- private var sphereList = new List.<GameObject>();
- function Start()
- {
- InvokeRepeating("SpawnBall", 0.0, 5.0);
- }
- function SpawnBall()
- {
- var newSphere : GameObject = Instantiate(sphere, transform.position, transform.rotation);
- sphereList.Add(newSphere);
- }
- function Update()
- {
- ClearList();
- }
- function ClearList()
- {
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- Debug.LogWarning("Deleting Spheres");
- for(var i = 0; i < sphereList.Count; i++)
- {
- Destroy(sphereList[i]);
- }
- sphereList.Clear();
- }
- }
Add Comment
Please, Sign In to add comment