Always cache GetComponent(s) in awake, unless…you can’t
AM I correct or am I off track?
Thanks
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.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.