Search Unity

Feature Request Events for grids and tilemaps

Discussion in '2D Experimental Preview' started by DavidNLN, Jun 16, 2019.

  1. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    Hello, I think it will be really nice if we could listen to changes on the grid.
    Right now the only way to do that is to create a new brush that will intercept the actions and send a message for you.

    That is limited however, as the methods signature does not include the brush current tile, you can get it, if you play around with the brushcell, but that is to cumbersome.

    I suggest a simple set of delegates that will provide the registrar the position(s) and tile(s) changed

    OnDraw
    OnFill
    OnErase
    and so on for the rest of the actions.

    maybe even a more general of an OnChange if you do not care for the specifics.
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    283
    Just to clarify, you would like a callback when the Tilemap changes with the position/s where the change occurred and the Tiles that have been changed?
     
  3. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    Tiles have been changed.

    My current use case is like so:
    I have a really large world (12000X12000 tiles) So I save the data to a flatBuffer and read it as the player moves around the world.

    For the development I want to get an event when my artist draws on the map so I can mutate the buffer as she draws.
    I could do this with a save button, but that means iterating over 12000X12000 tiles each save instead of just marking the tiles changed as dirty. and saving just them.

    To do this I need some kind of way to know which tile was changed.
    My current way of doing this is creating a brush that inherits from the DefaultBrush and then on draw figure out which tile map and which tile was is being drawn on.
    Tha annoying part is that I cant get the Tile itself without using the m_cells with the ```
    GetCellIndexWrapAround```
    method, both of which I dont think I'm supposed to touch.

    So instead I call all my logic after the paint is done and sample the tile at the draw location.
    All of this is a tedious process and took some time to figure out, an event system would solve this and make everything very straight forward.