Hi everybody, when I’m painting on a Grid that has several Tilemaps, like several depth layers, I’m all the time switching among tilemaps to add details to each layer in the same area of the grid. It’s a bit annoying to use the Active Tilemap dropdown all the time, it requires 2 clicks + visual search. I could use the Hierarchy browser, docking it next to the Tile Palette, but it would occupy some extra space on screen.
I’m not sure about what should be the solution but for me it would be worth a try.
[MenuItem("Shortcuts/Tilemap Next &t")] // alt+t
public static void OpenNextTilemap() => NextTilemap(move: 1);
[MenuItem("Shortcuts/Tilemap Prev #&t")] // shift+alt+t
public static void OpenPrevTilemap() => NextTilemap(move: -1);
static void NextTilemap(int move)
{
EditorApplication.ExecuteMenuItem("Window/2D/Tile Palette");
var targets = GridPaintingState.validTargets
.OrderBy(go => go.transform.GetSiblingIndex()).ToArray();
int now = System.Array.IndexOf(targets, GridPaintingState.scenePaintTarget);
if (now != -1)
{
int next = now + move;
if (next >= targets.Length) next = 0;
else if (next < 0) next = targets.Length - 1;
GridPaintingState.scenePaintTarget = targets[next];
EditorGUIUtility.PingObject(GridPaintingState.scenePaintTarget);
}
else Debug.LogWarning($"No valid Tilemap Targets");
}
It cycles tilemaps by their transform sibling order. Works perfectly for a simpIe hierarchy. If you have a complex hierarchy, you might want to adjust that.