Search Unity

some question about tilemap

Discussion in '2D' started by clearlovelove, Apr 11, 2021.

  1. clearlovelove

    clearlovelove

    Joined:
    Apr 11, 2021
    Posts:
    6
    how to design my own tile Class .... i mean how to inherit it
     
  2. clearlovelove

    clearlovelove

    Joined:
    Apr 11, 2021
    Posts:
    6
    methods and props means what?
     
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    You can inherit a new tile like so:
    Code (CSharp):
    1. [CreateAssetMenu(fileName = "New MyTile", menuName = "Tiles/MyTile")]
    2. public class MyTile : TileBase
    3. {
    4.          public Sprite sprite;
    5.  
    6.         public override void GetTileData(Vector3Int cell, ITilemap tilemap, ref TileData tileData)
    7.         {
    8.             tileData.sprite = sprite;
    9.         }
    10. }
    This is a very basic tile. You can create a new Tile by right clicking in the Project and going to Create >> Tiles >> MyTile. Once created, you can assign a sprite in the Inspector.

    You can find examples of more advanced tiles here: https://github.com/Unity-Technologies/2d-extras/tree/master/Runtime/Tiles
    You should take do some searches in YouTube for C# lessons. These are core concepts in C# so you should get familiar with them because it's hard to do anything without an understanding of them.
     
    clearlovelove likes this.
  4. clearlovelove

    clearlovelove

    Joined:
    Apr 11, 2021
    Posts:
    6
    Thx