I seem to be misunderstanding part of Unity. I'm generating a maze similar to the one here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/
I put the whole of the generation in Update()
and used a bool
to ensure it only runs once. However, right now the whole thing runs before the editor becomes available - it behaves exactly as if I had the whole thing in a Start()
section. Do I need to use coroutines to watch it build out? In the link above, if you click the first demo box, you can watch the maze place itself and build. I'd like to be able to see that in the scene view in Unity. Thoughts?
Edit:
This is my Update()
method currently:
void Update()
{
while (_continue)
{
_continue = false;
Dictionary<String, Tile> _dict = FetchTileList();
Tile _wall = _dict["Wall"];
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
var _go = Instantiate(_wall.gameObject, new Vector3(x, y, 0), Quaternion.identity);
}
}
_addRooms();
for (var y = 1; y < height; y += 2) {
for (var x = 1; x < width; x += 2) {
Vector2 pos = new Vector2(x, y);
Rect _rect = new Rect(x, y, 1, 1);
bool _add = true;
foreach (var other in _rooms)
{
if (_rect.Overlaps(other))
{
_add = false;
}
}
if (_add)
{
_growMaze(pos);
}
}
}
}
}
Update()
method. – SurvivalMachine Sep 08 '16 at 12:06Update()
, regardless of timing. I expected that rendering would occur at a fixed time, regardless of update. But that still isn't a solution. Would calling coroutines that performed the work resolve the issue, or will update not continue until the coroutine is finished? Should I call each loop once per update until the loop has completed? – Jesse Williams Sep 08 '16 at 13:15