Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 774 Bytes

USP0007.md

File metadata and controls

26 lines (17 loc) · 774 Bytes

USP0007 Don't flag fields with SerializeField or SerializeReference attributes as never assigned

Fields with the SerializeField or SerializeReference attributes should not be marked as unassigned.

Suppressed Diagnostic ID

CS0649 - Field is never assigned to, and will always be null

Examples of code that produces a suppressed diagnostic

using UnityEngine;

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

Why is the diagnostic reported?

The compiler detected an uninitialized private field declaration that is never assigned a value.

Why do we suppress this diagnostic?

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