AI Command Lab // Flight Simulator
203D: The Event Dial
Initial AI Output (Fragile)
// AI-Generated Code: The "Public" Trap
public void FireWeapon() {
// Audit Fail: This method must be Public to be seen by the Inspector.
// Now anyone can call it, breaking encapsulation.
...
}
Initial AI Prompt
"You ask the AI: "Make the button fire the weapon.""
Pilot Comm Link
Mission Objective: A skilled Pilot directs the AI to Register Callbacks. You command: "Keep the logic private and bind the ClickEvent inside the OnEnable method."
Optimized Protocol
// Corrected: Private & Secure
void OnEnable() {
root.Q<Button>("FireBtn").RegisterCallback<ClickEvent>(evt => Fire());
}
private void Fire() { ... }