Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Unity crashes when I place my tiles.

Discussion in '2D' started by GoodAIUser, Jun 16, 2023.

  1. GoodAIUser

    GoodAIUser

    Joined:
    Jul 15, 2020
    Posts:
    11
    My code is this:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Tilemaps;
    5. public class MakeTiles : MonoBehaviour
    6. {
    7.     public Tilemap map;
    8.    
    9.     public Tile[] avTiles = new Tile[16];
    10.  
    11.     private Vector3Int pos;
    12.     void Start()
    13.     {
    14.         for (int y=0;y < map.size.y; y++)
    15.         {
    16.             for (int x=0;x < map.size.x; x++)
    17.             {
    18.                 pos = new Vector3Int(x, y, 1);
    19.                 map.SetTile(pos, avTiles[0]);
    20.             }
    21.         }
    22.     }
    23.  
    24.    
    25.     void Update()
    26.     {
    27.        
    28.     }
    29. }
    30.  
    Now I don't understand what I am supposed to fill avTiles with I have been using my spritesheet files.

    I really don't need any type of behavior for these.
     
  2. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
  3. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    use coroutine to place tiles slowly, doing it all on the same frame is too heavy