- Home /
Question by
stingman · Jul 17, 2012 at 04:21 AM ·
coroutineoptimizationgetcomponentcachegameobject.find
Performance issues with GetComponent/gameObject.Find in different functions
Whenever I get use GetComponent in the Update function I always cache the component in the start function. But is there a reason to do this if you are using a coroutine like OnTriggerEnter or OnCollisionEnter or anything else that does not run once per frame? I'm just looking at performance optimization.
Comment
Best Answer
Answer by Eric5h5 · Jul 17, 2012 at 05:00 AM
Not really; GetComponent isn't that slow, so there's not much point caching it if it's not going to be accessed frequently.