Tier 2
Series 101
101B: Serialization Limits
"If you pack a suitcase with items the airline doesn't recognize, they throw them out. Unity's Inspector is the same. It can only "pack" (serialize) certain types of data. If your AI generates a complex class and it doesn't show up in the Inspector, you've created Invisible Data."
The Concept: The Serializable Attribute
Unity's Inspector can only "see" certain types of data automatically (int, float, string, Vector3). If you create a custom class (like `ItemStats`), Unity ignores it unless you explicitly tell it to "Serialize" it.
* **[System.Serializable]:** A tag you place above a custom class to tell Unity, "Please show this in the Inspector."
* **[System.Serializable]:** A tag you place above a custom class to tell Unity, "Please show this in the Inspector."
Red Flag Detected
The AI Trap: "The Invisible Data"
You ask the AI: "Create a class to store Inventory Item stats and show it in the Inspector."
// AI-Generated Code: Valid C#, but Invisible in Unity
public class ItemStats {
public int weight;
public int cost;
}
public class Inventory : MonoBehaviour {
public ItemStats stats; // Audit Fail: Won't show up!
}
This is "Inspector Blindness." The code compiles, but the `stats` field will not appear in the Unity Editor, making it impossible for designers to balance the game.
Elite Telemetry
Research shows "Elite" teams achieve 15% faster lead times by keeping AI on a "very tight leash."
- Small Batches Solving one problem at a time prevents logic drift.
- Modular Design Localizing the "blast radius" of AI changes.
- Tight Loops Rapid iteration with constant code review.
The Mechanic's Correction
Corrective Protocol
// Corrected: Visible and Editable
[System.Serializable] // The Magic Tag
public class ItemStats {
public int weight;
public int cost;
}
public class Inventory : MonoBehaviour {
public ItemStats stats; // Audit Pass: Now shows a foldout!
}
Your Pilot Command
> Direct the AI to use ReadValue to get the vector for 2D movement.