Advertisement
tomicz

Untitled

Jun 17th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 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. DinSp = GameObject.Find("Dynamic Spawner").GetComponent<DynamicSpawner>();
  21. tmsh = obj[0].GetComponent<TextMesh>();
  22. obj[0].AddComponent<BoxCollider2D>();
  23. DynamicObjectSpawner();
  24. }
  25.  
  26. // Update is called once per frame
  27. void Update()
  28. {
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. }
  36.  
  37. void DynamicObjectSpawner()
  38. {
  39.  
  40. linesInFile = TextFile.text.Split('\n');
  41.  
  42. foreach (string line in linesInFile)
  43. {
  44. Instantiate(obj[0], transform.position, Quaternion.identity);
  45. //obj[0] = new GameObject("Platform");
  46. obj[0].AddComponent<TextMesh>();
  47. tmsh = obj[0].GetComponent<TextMesh>();
  48. tmsh.text = line;
  49. }
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement