CS003errorFree tier

csharp-expensive-find-in-update

Expensive Unity lookups inside Update() cause frame rate drops

Applies to: C#

Why this matters

Unity's Update(), FixedUpdate(), and LateUpdate() run every frame. Calling GameObject.Find, FindObjectOfType, GetComponent, or Resources.Load inside them re-scans the scene or reflects into assemblies tens or hundreds of times per second. The canonical fix is to cache the reference once in Awake() or Start() and reuse the cached field.

Catch it before it ships

pip install stablestack # or: npx stablestackstablestack # scans your project, CS003 includedstablestack explain CS003

False positive in your codebase? Suppress a single line with # noqa: CS003