miepzerino
2023-12-23 eab47305629d96d19626e10b649ba4247d1f55f5
Assets/GenerateTileMap.cs
@@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
@@ -13,15 +13,13 @@
    Tilemap tilemap;
    public RuleTile ruleTile;
    //public List<TileBase> tiles;
    // Start is called before the first frame update
    void Start()
    private void Awake()
    {
        tilemap = GetComponent<Tilemap>();
        GenerateTiles();
    }
    public void GenerateTiles()
    public IEnumerator GenerateTiles(Action finishedCallback)
    {
        for (int x = 0; x < width; x++)
        {
@@ -33,16 +31,17 @@
                if (perlinNoise >= 0.3f)
                {
                    if (!tilemap.HasTile(new Vector3Int(x,y+1))) {
                        tilemap.SetTile(new Vector3Int(x, y), ruleTile);
                    }
                    else
                    {
                        tilemap.SetTile(new Vector3Int(x, y), ruleTile);
                    }
                }
            }
            // Update UI every 8 lines
            if ((x % 8) == 0)
            {
                yield return null;
        }
    }
        finishedCallback();
    }
}