TileData question

I am creating a custom tile that implements TileBase but I have an enum we’ll call:
enum Type { center, right, left, isolated }
I want each tile to store which type it is because I want to write logic in my custom tile that dictates the sprite based on that type.

I know under the intended circumstances tile logic uses neighboring tiles to then decide which sprite to use, but in this case I want to place tiles through a script that defines the type, then I want the tile class to define in GetTileData which sprite to use based on its assigned type.

Now I know I could use separate assets for each type but they are all thematically the same and I would like to avoid having multiple asset files for 1 tile set.

Is it possible to store info in each tile and not have it affect all tiles? Can I modify TileData or make my own and use it somehow?

Well, I would imagine you have your tiles tagged so you could gather them into an array on Start() by using FindObjectsWithTag()

private GameObject[] centerTileArray;
private GameObject[] rightTileArray;
private GameObject[] leftTileArray;
private GameObject isoTileArray;

private void Start()
{
centerTileArray = GameObject.FindObjectsWithTag("center");
// do this for each array

foreach(GameObject tile in centerTileArray)
{
// Here you can set information into each tile
// Best results would be to create a method to determine
// coordinates of tile so you can set specific-individual
// logic
}
}

Now if you want, you can [SerializeField] on your arrays and should be able to insert your tiles into it manually (maybe… never tried it). Then since you know exactly which element the tile is inside the array you can easily access it through code.

I realize you’re trying to use enum to locate your tiles and insert parameters. I’m offering a different approach to that.

I like your idea but in this case I’m not using GameObject tiles that I can add tags to I’m using unity’s Tilemap system and the TileBase class we are supposed to inherit is not unique in each tile on the tilemap, only the TileData is unique on each tile. Meaning TileBase derivatives can only store data that affects every tile of it’s type. TileData in this case is not something I can edit or overload (I don’t think), and is a file that is automatically used by Unity’s tilemap system and holds the individual and differing data of each tile. If I could make unity use my own form of TileData, that is more what I am asking if I can do. Sorry if I make little sense its hard to explain unless you’ve tried to create custom unity tiles.

You should absolutely be able to create tile palettes and give them each a tag. You’d only need to paint them on for your specific needs. However, if this doesn’t work for you, you can try this, scriptable tiles.

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