The Performance Heroes:
- Cached references in Awake()
- SerializeField in Inspector
- GetComponent for local components
- One-time initialization searches
WHEN TO USE WHAT:
- 1. GameObject.Find() & FindObjectOfType()
- One-time setup in Awake()
- Prototyping & quick tests
- Not for regular gameplay updates
- Not for physics or input handling
2. GetComponent<T>()
- Getting sibling components
- Initialization in Awake/Start
- Not for every frame updates
- Not for repeatedly accessing the same component
3. GetComponentInChildren<T>()
- One-time setup of hierarchies
- Not for continuous parent-child communication
- Not for frame-by-frame checks
Pro Tips:
- Cache everything you'll use more than once
- Use [SerializeField] for direct references
- Design hierarchies to minimize searches
- Consider Scriptable Objects for global data
ALL THE COMPONENT COMMUNICATION FUNCTIONS:
Direct References
- GetComponentInChildren<T>()
- GetComponentInParent<T>()
Search Methods