Guest User

Untitled

a guest
Jul 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #pragma strict
  2. import System.Collections.Generic;
  3.  
  4.  
  5. var sphere : GameObject;
  6. private var sphereList = new List.<GameObject>();
  7.  
  8. function Start()
  9. {
  10. InvokeRepeating("SpawnBall", 0.0, 5.0);
  11. }
  12.  
  13. function SpawnBall()
  14. {
  15. var newSphere : GameObject = Instantiate(sphere, transform.position, transform.rotation);
  16. sphereList.Add(newSphere);
  17. }
  18.  
  19. function Update()
  20. {
  21. ClearList();
  22. }
  23.  
  24. function ClearList()
  25. {
  26. if (Input.GetKeyDown(KeyCode.Escape))
  27. {
  28. Debug.LogWarning("Deleting Spheres");
  29. for(var i = 0; i < sphereList.Count; i++)
  30. {
  31. Destroy(sphereList[i]);
  32. }
  33.  
  34. sphereList.Clear();
  35. }
  36. }
Add Comment
Please, Sign In to add comment