I needed to find a better way to find my Game Objects without using GameObject.Find because I have this line more than 30 time is one script, so I created this line on my script:
public List<GameObject> gameObjectList = new List<GameObject>();
Then, I go in the inspector and add manually the gameobjects in the list.
and everything works fine. But I see nobody talking about that way on this forum, Stackoverflow or other websites, so is there something wrong with that way?
There is nothing wrong with this method, but depending on how you are using it there might be (even) more efficient ways.
are you “finding” gameobjects in this smaller list by name?, then you might aswell just have unique reference for each object. But if you need to go through all these objects to then update them all, then yes this is a perfectly fine way of organizing them
Your manual way should work, unless anymore is added to the scene.
And while GameObject.find is inefficient to run on every frame, it should be just fine to do it when the scene is initialized, and you can have the results save to that same list you made.
This would cache the find so it only has to do it once.