So the problem is the following: I have auto generated a maze and now try to add a map so that the player can see where he/she currently is. My problem is that I dont know how to manage to align my ui elements that they resemble my maze.
Here is my code till now:
using UnityEngine;
using UnityEngine.UI;
public class ShowMaze : MonoBehaviour
{
public Image RoomPrefab;
public GameObject Player;
public GameObject[] Rooms;
bool instantiated = false;
void CreateRooms()
{
foreach(GameObject Room in Rooms)
{
var room = Instantiate(RoomPrefab, transform.position, Quaternion.identity);
room.transform.parent = this.transform;
}
}
IEnumerator TestIfInstantiate(GameObject[] tempAry, float waitTime)
{
int oldLength = tempAry.Length;
yield return new WaitForSeconds(waitTime);
int length = tempAry.Length;
if(length == oldLength && !instantiated)
{
instantiated = true;
CreateRooms();
}
}
void Update()
{
Rooms = GameObject.FindGameObjectsWithTag("Room");
StartCoroutine(TestIfInstantiate(Rooms, 1));
}
}