How can I find adjacent 2D tiles without using colliders?

Everything I find on this tells me to use OverlapCircle, however I cannot as my colliders cover multiple tiles. I also cannot check for a collider as I need to access information on the specific tile at that location, and since the collider is not specific to that (or any) tile, this fails.

I’ve tried storing the information about the tile that I need outside the tile itself, however I’ve not managed to access the information based on Vector2 coordinates as the map position frequently changes making this difficult. I also want to avoid iterating through the list as this script is going to be run very frequently making performance important.

EDIT: Found a solution, posted below.

why not do a data monobehaviour class for the tiles and a static controller, giving tiles an index property and use a 2 dimensional array in the controller to access them, this is very efficient and flexible tracking system. You will need to make an add and subtract tile function for the controller. this system requires a lot of work to make but is very efficient

public class tile : monobehaviour {
public vector2 index ={x,y}
}

public static class controller {

public tile[,]tiles = new tile[maxX,maxY]();

findTileRight(vector2 index) {
return tiles [index.x + 1 , index.y ];
    }
}

i seen your post and i also have a block movement project i am working on, so i thought id let you know what my final arrangement was. first of all, I have tested levels with over 5 thousand blocks with box coliders and doesent show any noticable different in preformance. i even tested the build on a machine with a slower dual core processer. attaching scripts to blocks is a huge NO! but simple colliders does NOT slow the camera/game. if your only problem is your colliders being the wrong size you can simply create a child object with its own collider and its own script to get you secondary info from a smaller secondary collider. this way you can detect different distance collitions from the same object.

there might be other opinions out there but my soulution to storing info about a block on a very large level was simple strings. raycasting and spherecasting wait for returns from the unity game engine, which everyone here knows will slow a game when called every frame.

storing unity GameObject referenses in a large array stores all kinds of info by default such as names, components and many numbers after location decimal points that are completely worthless to my block based game. and are not even possible to send rpc call for muiltiplayer cause its too much bandwidth.

with unitys standard way of storing info my game and level size was not even possible. now my “outside of the box” threory has got my game running super smooth…

packing things into strings on a need to know basis.

its super fast for a pc to read a large string. let me know if you need more info.

A bit inefficient, but I’ve come up with a solution.

In short, I’ve decided to store the Vector2 positions of my tiles in their names, and use GameObject.Find to retrieve them. Despite my worries about said method being performance intensive, testing thus far shows no meaningful impact.

More details:

Setting the name in Awake, since the function that looks for tiles is usually called almost immediately after creation

void Awake ()
{
    gameObject.Name = (Convert.ToInt32 (transform.position.x) + "," + (Convert.ToInt32 (transform.position.y));
}

Looking for neighboring tiles

// X and Y are variables for this tiles position
GameObject yup = GameObject.Find ((x) + "," + (y + 1));
GameObject xright = GameObject.Find ((x + 1) + "," + (y));
GameObject ydown = GameObject.Find ((x) + "," + (y - 1));
GameObject xleft = GameObject.Find ((x - 1) + "," + (y));

And finally, check if tiles were found

if (yup != null)
{
    // there is a tile above, do stuff
}