Change string value with buttons C# Unity2D

Viewed 28

i'm trying to build a level editor when i click the button that calls WoodenWallTile() the string isn't changed to "wooden wall tile" so only the floor tile places on the tilemap, i'm wondering how i can change the selectedTile string value with a button?

above update()

public TileBase woodenFloorTile;
public TileBase woodenWallTile;
private string selectedTile = "wooden floor tile";

in update()

            foreach (Vector2Int cell in area.allPositionsWithin)
        {
            Vector3Int pos = (Vector3Int)cell;
            if (selectedTile == "wooden wall tile")
            {
                tilemap.SetTile(pos, woodenWallTile);
            }
            if (selectedTile == "wooden floor tile")
            {
                tilemap.SetTile(pos, woodenFloorTile);
            } 
           
            
            interactiveTilemap.ClearAllTiles();
        }

wall tile button calls

    public void WoodenWallTile() {
    selectedTile = "wooden wall tile";
    Debug.Log("IT CHANGED TO WALL");
}
0 Answers
Related