AI Command Lab // Flight Simulator
203B: The Visual Query
Initial AI Output (Fragile)
// AI-Generated Code: Slow & Risky
void UpdateScore() {
// Audit Fail: GameObject.Find is incredibly slow.
// If two labels are named "Score", it might break.
GameObject.Find("ScoreLabel").GetComponent<Text>().text = "100";
}
Initial AI Prompt
"You ask the AI: "Update the score label.""
Pilot Comm Link
Mission Objective: A skilled Pilot directs the AI to Cache the Query. You command: "Cache the Label reference in OnEnable using root.Q<Label>, then update it directly."
Optimized Protocol
// Corrected: Cached Reference
Label scoreLbl;
void OnEnable() {
scoreLbl = root.Q<Label>("Score");
}
void UpdateScore() => scoreLbl.text = "100";