FindObjectOfType vs. GameObject.Find

just a quick question as I am continuing to work through various tutorials…

which is more efficient for accessing functions in other object’s scripts- FindObjectOfType or GameObject.Find?

You only need to worry about efficiency in this regard, if you’re going to be doing this a lot (i.e. every frame, or many times per frame).

In this situation just use either method, but do it only once - in your Start() function. Put the result into a variable of the correct type, and from then onwards use your reference stored in that variable.

  • Ben
1 Like

thanks for the reply!

-good tip on putting it into Start- I had tried to put it into a var at the top, but it didn’t work, so this was just what I had missed out on

so much to learn…