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.

Programmatically placing tiles from scriptable tile

Discussion in 'Scripting' started by CheekySparrow78, Jul 11, 2019.

  1. CheekySparrow78


    Feb 9, 2019
    Hi folks,
    I have a question regarding one scriptable tile functionality that I consider useful but I cannot find any mentions of it.
    I've implemented a custom scriptable tile to seamlessly connect wall tiles that I am placing and now I'm trying to make my scriptable tile automatically surround itself by "padding" tiles when placed.
    For example, a typical wall in a top-down 2.5d game.

    XXXXX - X are tiles I actually place, represent top of the wall.
    YYYYY - Y are "padding" tiles that represent side of the wall, that may contain decorations, lanterns, windows, etc; I'm trying to make them placed automatically if there's no obstacle.
    However "RefreshTile()" method exposed by scriptable tiles refreshes tiles continuously, not just when the tile is placed, so if I call "setTile" from overridden "RefreshTile", it just leaves a trail of tiles on a tilemap as I move my mouse cursor. Should I implement this functionality using Scriptable Brushes? It feels wrong, because I think Scriptable tile should support something like this. Any insights would be much appreciated.