Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class DynamicSpawner2 : MonoBehaviour {
- public TextAsset textFile;
- public string[] textLines;
- public GameObject platform;
- private TextMesh linesMesh;
- int counter = 0;
- private BoxCollider2D boxCol;
- private MeshRenderer renMesh;
- public Transform spaceGenerator;
- // Use this for initialization
- void Start () {
- renMesh = platform.GetComponent<MeshRenderer>();
- boxCol = platform.GetComponent<BoxCollider2D>();
- linesMesh = platform.GetComponent<TextMesh>();
- spaceGenerator = spaceGenerator.GetComponent<Transform>();
- Spawn();
- }
- /*public void PlatformSpawner()
- {
- foreach (string StringLine in textLines)
- {
- linesMesh.text = StringLine;
- }
- }
- */
- public void Spawn()
- {
- textLines = textFile.text.Split('\n');
- boxCol.size = new Vector2(renMesh.bounds.size.x - 0.6f, 0.2f);
- Instantiate(platform, transform.position, Quaternion.identity);
- linesMesh.text = textLines[counter++];
- Invoke("Spawn", boxCol.size.x - 1f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement