Get Component in Start() vs Update()

I placed my GetComponent in the Start function, is there any performance issues or benefits between Start or Update for this?

1 Like

There can definitely be a performance bonus to caching your component references. A couple things to consider:

  • Only cache references you know are not going to change. Generally, any class on the same GameObject is a great candidate, but caching references to components on other GameObjects could become “stale”, if it’s destroyed, for example.
  • Opt to cache component references in Awake() rather than Start(), but don’t act on those references until OnEnable(), Start() or later. This helps to prevent many common race conditions.
3 Likes

Privacy & Terms