Performance: Mouse input (GetMouseButton, position)
MEDIUM IMPACT
This affects the responsiveness and smoothness of user interactions by how often and efficiently mouse input is checked and processed.
void Update() {
if (Input.GetMouseButtonDown(0)) {
Vector3 pos = Input.mousePosition;
// lightweight processing or defer heavy work
}
}void Update() {
if (Input.GetMouseButton(0)) {
Vector3 pos = Input.mousePosition;
// heavy processing here
}
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Polling GetMouseButton every frame with heavy processing | N/A | N/A | Blocks frame rendering causing jank | [X] Bad |
| Using GetMouseButtonDown to trigger input once per click | N/A | N/A | Minimal impact on frame rendering | [OK] Good |