Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to make procedual tilemap with tilemap component?

Discussion in '2D' started by lkho0215, Nov 10, 2019.

  1. lkho0215

    lkho0215

    Joined:
    Jan 29, 2015
    Posts:
    1
    I would like to make a pocedual tilemap. I tried to use the SetTile funciton but it seem nothing happened and I couldn't see any tile that has set.

    Code (CSharp):
    1.  
    2.     public Tilemap tilemap;
    3.     public TileBase tile;
    4.  
    5.     // Start is called before the first frame update
    6.     void Start()
    7.     {
    8.         tilemap.SetTile(new Vector3Int(10, 10, 0), tile);
    9.        
    10.         Debug.Log("Start");
    11.     }
    12.  
    13.  
     
  2. blu3drag0n

    blu3drag0n

    Joined:
    Nov 9, 2018
    Posts:
    55
    TileBase is wrong, it's just the basclass of Tile.
    Use Tile instead.

    Anyways: what have you assigend to "tile".

    IMHO if you already have trouble yet with the very first line of code then generating a procedural tilemap (which mostly ends up in a sandbox game) might be too mich for the very beginning.
    Please read through some of the Unity docs in regards of Tilemap system.
    https://docs.unity3d.com/ScriptReference/UnityEngine.TilemapModule.html
    https://docs.unity3d.com/2018.3/Doc...31.711119688.1572370756-1998841015.1569750480

    Maybe some guidelines from the Unity Learn platform.
    https://learn.unity.com/tutorial/introduction-to-tilemaps?language=en

    And maybe some of the parts in my guide might be also helpful
    https://forum.unity.com/threads/sha...before-starting-with-tilemaps-2d-2-5d.771020/

    KR