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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Tilemap select and move a region on multiple layers

Discussion in '2D' started by Threepwood, Apr 28, 2020.

  1. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    95
    With a Tilemap you can select an area of tiles and move them and that's great, for that tilemap layer.

    If you have multiple layers is there any way to select a region and move all the layers (bg, solid, fg, prefab objects etc) at once? Having to select/move each layer independently isn't great.

    Maybe I missed a feature? Would be great if so.
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,323
  3. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    95
    I just meant different tile maps ie: one for background, foreground, what you walk on, objects/prefabs, etc. Purely a workflow thing when you want to move sections of a map around that involves several different tile maps.

    Will look over your links in any case.
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,323
    Code (CSharp):
    1. Tilemap tilemap = brushTarget.GetComponent<Tilemap>();
    Namely, it should be productive to replace this line with something like:
    Code (CSharp):
    1. Tilemap[] tilemaps = brushTarget.transform.parent.GetComponentsInChildren<Tilemap>();
    Then manipulate them all in tandem, if wanting to affect them all (assuming your hierarchy is typical). I'm sure you'll be able to get started without much issue.
     
  5. tbngrd

    tbngrd

    Joined:
    Jul 25, 2018
    Posts:
    12
    I'm currently trying to do the same thing, I'm wondering if you had any success with this, @Threepwood ?
     
  6. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    95
    I reached out to Unity on Twitter about it and a patch showed up a day later:

    https://github.com/Unity-Technologies/2d-extras/tree/layerbrush

    You have to grab the layerbrush branch of the 2d-extras package on github. Then there's a new brush in the tilemap window that has a layer brush. When selected it will move all layers around (except the gameobjects/prefab brushes). On that...I just stopped using prefab brushes and instead have an atlas for objects icons. When the map loads I run through that layer and instantiate things. So bottom line, I can now easily select/move all the tilemap layers. It's clunky and you have to remember to select this brush to do it (vs it just being the damned default - or letting you select what tilemap layers to group) but it works.

    I have no idea why this is so clunky and not rolled into Unity by default. It's insane the 2d-extras and many other things are in flux and preview for so long and you have to get them from github to begin with. Unity is too fragmented in what they choose to focus and work on.
     
  7. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    556
    The 2d extras are just that.... extras. They never promised any of that should be integrated. It isn't as if its a preview package or something like that.
     
  8. tbngrd

    tbngrd

    Joined:
    Jul 25, 2018
    Posts:
    12
    Oh! That's a lot more that I had anticipated to be honest, thanks a lot for the quick reply! I don't use prefab brushes anyway, so this does exactly what I need. I tried to code it myself this afternoon but it wasn't going well so far, haha. This will make level design in my game a lot more straight forward.
     
    Last edited: May 24, 2020
  9. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    95
    Yeah except what’s there isn’t really good and there are things like the above feature that are extremely basic and necessary to production, non hobbyist, work.

    Add to that the 2d stuff like tile map editor has been in for years and is still bad.
    Would be nice if Unity ate their own dog food or tries to make real things with it. There are so many half done systems it isn’t even funny.
    It’s sad that 2d extras has been in preview for 2 years?
    So yeah. :)
     
  10. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    556
    I wholeheartedly agree about the dogfooding thing. Might be nice if they produced a large game.
    I think the tilemap system is nice, but I suppose my use case is rather different?

    Also cheers to your forum join date. Not many still around from that time.