Private fields with the SerializeField
or SerializeReference
attributes should not be marked as unused.
IDE0051 - Remove unused private members
using UnityEngine;
class Camera : MonoBehaviour
{
[SerializeField]
private string someField = "default";
}
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.
A field with the SerializeField
or SerializeReference
attributes are exposed and can be used in the Unity Inspector.