Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 820 Bytes

USP0006.md

File metadata and controls

26 lines (17 loc) · 820 Bytes

USP0006 Don't flag private fields with SerializeField or SerializeReference attributes as unused

Private fields with the SerializeField or SerializeReference attributes should not be marked as unused.

Suppressed Diagnostic ID

IDE0051 - Remove unused private members

Examples of code that produces a suppressed diagnostic

using UnityEngine;

class Camera : MonoBehaviour
{
	[SerializeField]
	private string someField = "default";
}

Why is the diagnostic reported?

The IDE does not detect that the field is ever used within the project. Therefore, under normal circumstances, it would be reasonable to remove the unused code.

Why do we suppress this diagnostic?

A field with the SerializeField or SerializeReference attributes are exposed and can be used in the Unity Inspector.