Advertisement
tomicz

Untitled

Jun 19th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DynamicSpawner2 : MonoBehaviour {
  5.  
  6. public TextAsset textFile;
  7. public string[] textLines;
  8. public GameObject platform;
  9. private TextMesh linesMesh;
  10. int counter = 0;
  11. private BoxCollider2D boxCol;
  12. private MeshRenderer renMesh;
  13. public Transform spaceGenerator;
  14.  
  15. // Use this for initialization
  16. void Start () {
  17. renMesh = platform.GetComponent<MeshRenderer>();
  18. boxCol = platform.GetComponent<BoxCollider2D>();
  19. linesMesh = platform.GetComponent<TextMesh>();
  20. spaceGenerator = spaceGenerator.GetComponent<Transform>();
  21. Spawn();
  22.  
  23. }
  24.  
  25. /*public void PlatformSpawner()
  26. {
  27. foreach (string StringLine in textLines)
  28. {
  29. linesMesh.text = StringLine;
  30.  
  31. }
  32. }
  33. */
  34.  
  35. public void Spawn()
  36. {
  37.  
  38.  
  39. textLines = textFile.text.Split('\n');
  40. boxCol.size = new Vector2(renMesh.bounds.size.x - 0.6f, 0.2f);
  41. Instantiate(platform, transform.position, Quaternion.identity);
  42. linesMesh.text = textLines[counter++];
  43. Invoke("Spawn", boxCol.size.x - 1f);
  44. }
  45.  
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement