Spawning Sprites on Certain Tiles

I am working on a top-down 2D lawnmowing game, and I want to spawn blades of grass on the level. I am using tilemaps to design levels and I am hoping to be able to place a green tile, and have grass blade sprites spawn randomly across those tiles when the level starts, but not across tiles that are sidewalks or roads. I have worked out how to spawn the sprites, but I have gotten stuck on trying to get information from the tilemap. Can anyone recommend a way to detect certain tiles in a tilemap (or any active tile in a grass specific tilemap), and have that communicate with a grass spawning script?

I think what you’re looking for is this:

https://docs.unity3d.com/Manual/Tilemap-ScriptableTiles.html

Caveat: I’ve not tinkered much with them but it seems they could (with perhaps additional scripting) do exactly what you want as far as special behavior in special parts of your map.

Approach 1: Using Scripting API to write additional tiles for the grass blades on top of grass tiles.

public class GrassSpawner : MonoBehaviour
{
    // connect these properties up in the Inspector
    public Tilemap grassTilemap;  // green tiles
    public Tilemap grassTuftTilemap;  // grass blades, needs to have order so that render on top of grassTilemap
    public TileBase grassTile;
    public TileBase grassTuft;
 
   void Start()
   {
       SpawnGrassTufts();
   }

    void SpawnGrassTufts()
    {
            foreach (var cell in grassTilemap.cellBounds.allPositionsWithin)
            {
                if (tilemap.GetTile(cell) == grassTile && Random.value < .33f)
                {
                    // 1/3 of grass tiles will receive grass tuft on top
                    grassTuftTilemap.SetTile(cell, grassTuft);
                }
            }
    }
}

Approach 2: use RandomTile

Another way to do this would be to create a RandomTile. See 2D Tilemap Extras package, available in the Package Manager. You would have the sprite sometimes be plain green. Other times, you’d use a different sprite: green plus blades.