Unity-Technologies / 2d-techdemos

Tech Demos for Unity 2D Features

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change active brush in Tile Palette with GridPaintingState.gridBrush

jlquijano opened this issue · comments

I need change active brush in Tile Palette when active tilemap change in Tile Palette. I subscribe to scenePaintTargetChanged event.

GridPaintingState.scenePaintTargetChanged += GridPaintingState_scenePaintTargetChanged;

....

private void GridPaintingState_scenePaintTargetChanged(GameObject obj)
{
Debug.Log("Active Tilemap is " + obj);
if (obj.name == "Foo" )
{
// how Can I change GridPaintingState.gridBrush to one of the available brushes in drop-down list
}
}

Thanks!

Sorry, it looks like the list of brushes is still internal to the Tilemap Editor code unfortunately. We will expose this in the future.

This is not ideal, but you could try to import and edit the code in the 2D Tilemap Editor package and change the GridPaletteBrushes class from internal to public?

Thank you! I will try this.
As a suggestion for improvement, an event in GridPaintingState would be useful when changing the palette. There could also be a way to change the active palette. I can't find a way to do it.
Good Work!

Yes, we will look into this for the palettes as well!