Does anyone know how to find a game object in runtime without GameObject.Find

I’ve been making a game of Mahjong but my main problem is checking which tiles are clickable.

Due to the fact that their “clickable” state is gonna change throughout the game i need a way to get that tile in code, and change its state but im really lost on how to find it because GameObject.Find and its alternatives drop me to 2 fps whenever the function they’re in is called

Can sb help me with this?

Hello @buzimkicsandi3. Could you share the code you are using? Without seeing it, I can only offer one, potential solution.

Use arrays. Arrays allow you to store multiple references in one container, and call on them individually.

So create an array in your script, then in the inspector, choose how long (or how many items long) your array is. Next, drag and drop the references to the tiles into the array. Then in your code, when you need to check a tile, check the corresponding number in the array.
I hope this helps, if you need any further assistance, just let me know. :slight_smile:

There Are Two Ways That I Know Try One Of These Maybe Its Works:

  1. GameObject Object = GameObject.FindWithTag(“tag”);
  2. GameObject Object = FindAnyObjectOfType();