Advertisement
tomicz

Untitled

Jun 18th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5.  
  6. public class DynamicSpawner : MonoBehaviour
  7. {
  8.  
  9. public TextAsset TextFile;
  10. public GameObject[] obj;
  11. private TextMesh tmsh;
  12. private DynamicSpawner DinSp;
  13. private string[] linesInFile;
  14. public float spawnMin = 0f;
  15. public float spawnMax = 0f;
  16.  
  17. // Use this for initialization
  18. void Start()
  19. {
  20. // Spawner();
  21. DinSp = GameObject.Find("Dynamic Spawner").GetComponent<DynamicSpawner>();
  22. tmsh = obj[0].GetComponent<TextMesh>();
  23.  
  24.  
  25. DynamicObjectSpawner();
  26.  
  27. }
  28.  
  29. // Update is called once per frame
  30. void Update()
  31. {
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. }
  39.  
  40. void DynamicObjectSpawner()
  41. {
  42.  
  43.  
  44.  
  45. linesInFile = TextFile.text.Split('\n');
  46.  
  47. foreach (string line in linesInFile)
  48. {
  49.  
  50. // obj[0] = new GameObject("Platform");
  51. tmsh = obj[0].GetComponent<TextMesh>();
  52. tmsh.text = line;
  53.  
  54. Spawner();
  55. }
  56.  
  57. }
  58.  
  59. private void Spawner()
  60. {
  61.  
  62.  
  63. Instantiate(obj[0], transform.position, Quaternion.identity);
  64. Invoke("Spawner", Random.Range(spawnMin, spawnMax));
  65.  
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement