Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. public GameObject[] tilePrefabs;
  2. private float spawnZ = -19.0f;
  3. private float tileLength = 24.0f;
  4. private List<GameObject> activeTiles;
  5.  
  6. private void DeleteTile()
  7. {
  8. //Destroy(activeTiles[0]);
  9. activeTiles[0].SetActive(false);
  10. activeTiles.RemoveAt(0);
  11. }
  12.  
  13. private void SpawnTile(int prefabIndx = -1)
  14. {
  15. GameObject go;
  16. if (prefabIndx == -1)
  17. {
  18. go = Instantiate(tilePrefabs[RandomPrefabIndex()])as GameObject;
  19. go.SetActive(false);
  20.  
  21. }
  22. else
  23. {
  24. go = Instantiate(tilePrefabs[prefabIndx]) as GameObject;
  25. go.SetActive(false);
  26. }
  27.  
  28. go.transform.SetParent(transform);
  29. go.transform.position = Vector3.forward * spawnZ;
  30. spawnZ += tileLength;
  31. //activeTiles.Add(go);
  32. go.SetActive(true);
  33. activeTiles.Add(go);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement