- Home /
Question by
SmashingSuccess · May 18, 2018 at 07:08 PM ·
tilemaptile
Why does setTile work for one, but not all three of my custom tiles?
My problem is rather simple. I am attempting to modify the tiles on one of three separate grids during runtime, but only the BaseTile modification works. BaseTile, UnitTile, and Tile Modifier are all custom tiles, holding nothing but simple ints, enums, and strings. There should be no reason that one works over, or that any do not work at all, so I am rather stumped here.
As a side note, BattleGrid is rather complicated, but for the purposes of this problem, it only holds references to each of the different tilemaps. I've even tested to make sure the references are correct, so that can be ruled out for the sake of saving space posting its code here.
public BaseTile basetest;
public TileModifier modtest;
public UnitTile unittest;
public BattleGrid myGrid;
public enum TilemapSelect
{
None = 0,
Base = 1,
Mod = 2,
Unit = 3
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.X))
{
ModifyTileOnGrid(TilemapSelect.Mod, new Vector3Int(0, 0, 0), basetest, modtest, unittest);
}
}
public void ModifyTileOnGrid(TilemapSelect grid, Vector3Int tileLoc, BaseTile baseMod = null, TileModifier modMod = null, UnitTile unitMod = null)
{
Tilemap tilemap = null;
switch (grid)
{
case TilemapSelect.Base:
tilemap = myGrid.tileGrid;
tilemap.SetTile(tileLoc, baseMod);
break;
case TilemapSelect.Mod:
tilemap = myGrid.modGrid;
tilemap.SetTile(tileLoc, modMod);
break;
case TilemapSelect.Unit:
tilemap = myGrid.unitGrid;
tilemap.SetTile(tileLoc, unitMod);
break;
case TilemapSelect.None:
Debug.Log("No proper grid selected.");
break;
}
}
Comment
Your answer
