- Home /
 
2D Tilemap increase custom Brush size
I am making a custom Brush and i cant get the brush to paint in anything but 1X1 area.
The Brush i am trying to make is a brush that has the size of 3X3 and in each tile randomly chose between sprites that fits that tile, we have 3x3 floor tiles so 1 corner of floor is 1x1. The Foreach loop is where i think the problem is, it executes only if the brush size is 1 will it work.
   //[tile[3]] [tile[3]] [tile[3]]
   //[tile[3]] [tile[3]] [tile[3]]
   //[tile[3]] [tile[3]] [tile[3]]
     public override void Paint(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
     {
         if (Tiles.Length > 0 && Tiles != null)
         {
             if (brushTarget == null)
             {
                 return; // If the Brush target is Null dont paint anything
             }
             var tilemap = brushTarget.GetComponent<Tilemap>();
             if (tilemap == null)
             {
                 return; // If i am not on a Tilemap dont do anythign
             }
 
             //size.Set(3,3,0); // <-- Dose nothing lul bug?
             //Debug.Log(size);
 
             size = new Vector3Int(3, 3, 0);
             Vector3Int min = position - pivot;
             BoundsInt bounds = new BoundsInt(min, size);
 
             //THIS foreach is where i am STUCK, 
             //it dose not work when i change the size to 3x3
              foreach (var location in bounds.allPositionsWithin) // Works if size 1x1
              {
                 Debug.Log("HELLO");
                 tilemap.SetTile(location, Tiles[0]);
              }
             // tilemap.SetTile(position, Tiles[0]); // 1X1 size.
         }
         else
         {
             Debug.Log("Position " + position.ToString());
             base.Paint(gridLayout, brushTarget, position);
         }
     }
 
               I might be trying to change the size with completely wrong code as i am using the unity random brush as a template for my brush.
I can probably figure out the random logic or i will ask in another thread so dont worry about that.
Your answer
 
             Follow this Question
Related Questions
Get a tile relative to its position in the world 1 Answer
2D Tilemap Gameobject Brush Script for Editor 0 Answers
Box collider 2d detecting collisions while not actually colliding 1 Answer
How can I find the name of the tile that I collided with in 2d? 1 Answer
Using Tilemap draw tools to change properties with custom editor 0 Answers