Tier 1
Series 6
6C: The Delegate Dispatch
"Fiber optics carry signals faster than steel cables. UnityEvents are user-friendly (steel cables), but they are "heavy." For high-frequency signals like "Score Updated" (60 times a second), you need the speed of raw C# Delegates (Fiber Optics)."
The Concept: C# Actions
An Action is a pure C# delegate. It is lightweight, extremely fast, and perfect for code-to-code communication.
Speed: Faster than UnityEvents.
Code Only: Cannot be seen in the Unity Inspector.
Syntax: public static Action OnScoreChange;
Speed: Faster than UnityEvents.
Code Only: Cannot be seen in the Unity Inspector.
Syntax: public static Action
Red Flag Detected
The AI Trap: "The Heavy Broadcast"
You ask the AI: "Create a system to update the score UI every time the score changes."
// AI-Generated Code: Performance Overhead
public UnityEvent<int> onScoreChange;
void AddScore(int amount) {
score += amount;
// Audit Fail: UnityEvents create garbage when invoked frequently.
onScoreChange.Invoke(score);
}
This is "Performance Overhead." For a simple integer passing between two scripts, a UnityEvent is overkill.
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: High-speed fiber optics
public static Action<int> OnScoreChange;
void AddScore(int amt) {
score += amt;
// The "?" checks if anyone is listening before sending
OnScoreChange?.Invoke(score);
}
Your Pilot Command
> A skilled Mechanic directs the AI to use a static C# Action. You command: "Use a static C# Action for high-speed, code-only communication."