UNT0013 Invalid or redundant SerializeField attribute
May 23, 2026 ยท View on GitHub
The SerializeField attribute is redundant for public non-dictionary fields, and invalid for static/readonly fields.
Examples of patterns that are flagged by this analyzer
using System.Collections.Generic;
using UnityEngine;
public class SerializedAttributes : MonoBehaviour
{
[SerializeField] // correct usage
private string privateField;
[SerializeField] // redundant usage
public string publicField;
[SerializeField] // correct usage for public dictionary fields
public Dictionary<string, string> publicDictionary;
[SerializeField] // invalid usage
static string staticField;
[SerializeField] // invalid usage
readonly field readonlyField;
}
Solution
Remove the SerializeField attribute when it is redundant or invalid:
using System.Collections.Generic;
using UnityEngine;
public class SerializedAttributes : MonoBehaviour
{
[SerializeField] // correct usage
private string privateField;
public string publicField;
[SerializeField] // correct usage for public dictionary fields
public Dictionary<string, string> publicDictionary;
static string staticField;
readonly field readonlyField;
}
A code fix is offered for this diagnostic to automatically apply this change.