Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

brushtarget is not the same in CustomGridBrush

Discussion in '2D' started by Shpendicus, Jun 14, 2020.

  1. Shpendicus

    Shpendicus

    Joined:
    Jan 12, 2018
    Posts:
    5
    I just recognized that the same tilemap-brushtarget is different when the both below functions are not used immediately for the same cell, like when their is a delay, like I Paint smth on X,Y, then again on X+1, Y+2, and go back to X,Y and try to erase and it suddenly doesnt see the brushtarget as the same as in the beginning when they were used immediately together, what can I do to maek this happen, since I need ggettile and settile of the brushtarget! Would be very cool if some1 could provide some help :/
    1. [CustomGridBrush(false, true, false, "Candy Random Brush")]
    2. public class MyRandomBrush : BasePrefabBrush
    3. {
    4. public override void Paint(GridLayout grid, GameObject brushTarget,
    5. Vector3Int position)
    6. {
    7. var current = brushTarget.GetComponent<TileMap>();
    8. }
    9. IS DIFFERENT TO:
    10. public override void Erase(GridLayout grid, GameObject brushTarget,
    11. Vector3Int position)
    12. {
    13. var current = brushTarget.GetComponent<TileMap>();
    14. }
    15. even tho I checked if its the same tilemap they refer to and they do?
    16. what is going on their, pls help, since I want the tilemap to "SetTile()" and"GetTile()"