Seems we are now going back to basics that we learned from previous class

Always cache GetComponent(s) in awake, unless…you can’t

AM I correct or am I off track?

Thanks

Yes, GetComponent should be used in awake or even better, serialize it so you set things the Editor, it might be cumbersome but there’s a tiny increase in performance. That being said, the method is still quite fast.

Use TryGetComponent instead when dealing with situations that don’t let you cache things right from the start.

Here’s an article that talks about performance, comparing generic vs non-generic methods, quite an interesting read.

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms