Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [System.Serializable]
- public class CharToPrefab{
- public char character;
- public GameObject prefab;
- }
- public class LevelReader : MonoBehaviour {
- public CharToPrefab[] prefabs;
- public TextAsset LevelText;
- private string LevelString;
- private string[] LevelStringLines;
- void Awake () {
- if (LevelText != null) {
- LevelString = LevelText.text;
- LevelStringLines = LevelString.Split ('\n');
- for(int height = 0; height <= LevelString.Length / LevelStringLines[1].Length; height++){
- for(int width = 0; width <= LevelStringLines[0].Length; width++){
- foreach(CharToPrefab ctp in prefabs){
- if(ctp.character == LevelStringLines[height].ToCharArray()[width]){
- Debug.Log ("Instantiate prefab here");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement