[QUALITY] Public fields should be [SerializeField] private for encapsulation #22

Open
opened 2026-03-12 00:03:38 +00:00 by lavarius · 0 comments
Owner

🟡 Medium — Code Quality

Several classes expose fields as public when they should be [SerializeField] private to maintain encapsulation while keeping Unity Inspector visibility:

  • Interactable.cs: interactionIcon, fadeSpeed, targetAlpha, minAlpha
  • Radio.cs: audioSource, radioStations, localMP3Files
  • CameraManager.cs: CameraPrefab, MainCameraInstance
  • WorkIndicator.cs: All fields

Fix:

// Before:
public AudioSource audioSource;

// After:
[SerializeField] private AudioSource audioSource;
## 🟡 Medium — Code Quality Several classes expose fields as `public` when they should be `[SerializeField] private` to maintain encapsulation while keeping Unity Inspector visibility: - `Interactable.cs`: `interactionIcon`, `fadeSpeed`, `targetAlpha`, `minAlpha` - `Radio.cs`: `audioSource`, `radioStations`, `localMP3Files` - `CameraManager.cs`: `CameraPrefab`, `MainCameraInstance` - `WorkIndicator.cs`: All fields **Fix:** ```csharp // Before: public AudioSource audioSource; // After: [SerializeField] private AudioSource audioSource; ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lavarius/ProjectOverlay#22
No description provided.