Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- public class DynamicSpawner : MonoBehaviour
- {
- public TextAsset TextFile;
- public GameObject[] obj;
- private TextMesh tmsh;
- private DynamicSpawner DinSp;
- private string[] linesInFile;
- public float spawnMin = 0f;
- public float spawnMax = 0f;
- // Use this for initialization
- void Start()
- {
- DinSp = GameObject.Find("Dynamic Spawner").GetComponent<DynamicSpawner>();
- tmsh = obj[0].GetComponent<TextMesh>();
- obj[0].AddComponent<BoxCollider2D>();
- DynamicObjectSpawner();
- }
- // Update is called once per frame
- void Update()
- {
- }
- void DynamicObjectSpawner()
- {
- linesInFile = TextFile.text.Split('\n');
- foreach (string line in linesInFile)
- {
- Instantiate(obj[0], transform.position, Quaternion.identity);
- //obj[0] = new GameObject("Platform");
- obj[0].AddComponent<TextMesh>();
- tmsh = obj[0].GetComponent<TextMesh>();
- tmsh.text = line;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement