Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. [System.Serializable]
  6. public class CharToPrefab{
  7. public char character;
  8. public GameObject prefab;
  9. }
  10.  
  11.  
  12. public class LevelReader : MonoBehaviour {
  13.  
  14. public CharToPrefab[] prefabs;
  15. public TextAsset LevelText;
  16.  
  17. private string LevelString;
  18. private string[] LevelStringLines;
  19.  
  20. void Awake () {
  21. if (LevelText != null) {
  22. LevelString = LevelText.text;
  23. LevelStringLines = LevelString.Split ('\n');
  24. for(int height = 0; height <= LevelString.Length / LevelStringLines[1].Length; height++){
  25. for(int width = 0; width <= LevelStringLines[0].Length; width++){
  26. foreach(CharToPrefab ctp in prefabs){
  27. if(ctp.character == LevelStringLines[height].ToCharArray()[width]){
  28. Debug.Log ("Instantiate prefab here");
  29. }
  30.  
  31. }
  32. }
  33. }
  34.  
  35.  
  36. }
  37. }
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement