Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Tile Map Populate tilemap-palette with custom TileBase class?

Discussion in '2D Experimental Preview' started by Kirsche, Aug 29, 2018.

  1. Kirsche


    Apr 14, 2015
    If you drag a sprite atlas onto the tilemap-palette Unity automatically generates the required tile-assets. However I'd like Unity to use my custom TileBase-inherited class for all tiles, so I can add a few useful properties like SurfaceType.

    Is there anyway to tell Unity to use my custom tile class?
  2. BlackHoleTracer


    Jan 23, 2014
    Yes, write your class (inherited from TileBase or Tile) and add to code of this class such lines:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. // The following is a helper that adds a menu item to create a MyTile Asset
    3.     [MenuItem("Assets/Create/MyTile")]
    4.     public static void CreateMyTile()
    5.     {
    6.         string path = EditorUtility.SaveFilePanelInProject("Save My Tile", "New My Tile", "Asset", "Save My Tile", "Assets");
    7.         if (path == "")
    8.             return;
    9.     AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<MyTile>(), path);
    10.     }
    11. #endif
    These lines will create new menu item (in Unity Editor) here: Assets->Create->MyTile. Click this and you will get your Tile.

    See Unity example here:
    And you can use shorter alternative - CreateAssetMenuAttribute ( )
  3. tgaldi


    Oct 28, 2015
    Is there a better solution for this? It seems cumbersome to have to create a new Tile object each time you want to add properties to a new sprite you want to make into a tile, as well as individually drag those new objects into the tile palette.

    Let's say I create a WallTile that has a property that says this tile is impassable. Every time I have a new sprite that represents a wall I would have to create another WallTile scriptable object, add the sprite asset to it, then drag it into the correct tile palette.

    Is there a way to customize the tile palette inspector to assign tile types to tiles already added to the palette?
    Last edited: Feb 6, 2019
  4. ChuanXin


    Unity Technologies

    Apr 7, 2015
    Unfortunately, this is not possible now. We will improve the Tile Palette to have this functionality.
    tgaldi likes this.