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()
- {
- // Spawner();
- DinSp = GameObject.Find("Dynamic Spawner").GetComponent<DynamicSpawner>();
- tmsh = obj[0].GetComponent<TextMesh>();
- DynamicObjectSpawner();
- }
- // Update is called once per frame
- void Update()
- {
- }
- void DynamicObjectSpawner()
- {
- linesInFile = TextFile.text.Split('\n');
- foreach (string line in linesInFile)
- {
- // obj[0] = new GameObject("Platform");
- tmsh = obj[0].GetComponent<TextMesh>();
- tmsh.text = line;
- Spawner();
- }
- }
- private void Spawner()
- {
- Instantiate(obj[0], transform.position, Quaternion.identity);
- Invoke("Spawner", Random.Range(spawnMin, spawnMax));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement