AI Command Lab // Flight Simulator
301A: The Global Compass
Initial AI Output (Fragile)
// AI-Generated Code: Dangerous and messy
public class ScoreManager : MonoBehaviour {
void Awake() {
// Audit Fail: If you return to this scene,
// a second ScoreManager will be created!
DontDestroyOnLoad(this.gameObject);
}
}
Initial AI Prompt
"You ask the AI: "Make a ScoreManager that stays alive between scenes.""
Pilot Comm Link
Mission Objective: A skilled Pilot directs the AI to use a Safe Singleton Pattern.
Optimized Protocol
public static ScoreManager Instance;
void Awake() {
if (Instance == null) {
Instance = this;
DontDestroyOnLoad(gameObject);
} else {
Destroy(gameObject); // Clear the deck of duplicates!
}
}