Quantcast
Channel: Answers for "How to GetComponent once for multiple comparisions"
Browsing all 4 articles
Browse latest View live

Answer by nsxdavid

Easy, you cache it yourself: Create a variable on your class to hold a reference to the component and do the GetComponent once in your start method and use that variable everywhere else in your class.

View Article



Answer by bunCBG

You can achieve something similar if all of your trigger classes are in the same hierarchy. For example: abstract public class AbstractTrigger : MonoBehavior { ... } public class LedgeTrigger :...

View Article

Answer by nsxdavid

Easy, you cache it yourself: Create a variable on your class to hold a reference to the component and do the GetComponent once in your start method and use that variable everywhere else in your class.

View Article

Answer by bunCBG

You can achieve something similar if all of your trigger classes are in the same hierarchy. For example: abstract public class AbstractTrigger : MonoBehavior { ... } public class LedgeTrigger :...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images