Optimisation - When to use Global variables or GameObject.Find() ?

Hi,

I was wondering about this as I’ve heard that if you are regularly referencing objects in a scene then it is better/more efficient to use Global variables rather then GameObject.Find() in real-time. Can anyone clarify this, and provide any more information on when to use each of these and how/where to assign them for maximum optimisation?

Thanks

best way for optimization is:

  • if you use GameObject.Find() more then once for some object, then you should use it once and store a link to it for future use.

you can store it in private variable, on in public static for other components can access it too