Code inspection: The layer is not defined in the 'Tags & Layers'
This inspection reports layer-related API calls that use a layer name not defined in the project's Tags & Layers settings.
This applies to APIs such as LayerMask.NameToLayer and LayerMask.GetMask. If the layer name does not exist, the call is likely to fail at runtime or return an unexpected result.
Example
In this example, the layer name "Enemies" is used, but only "Enemy" exists in the project's settings.
using UnityEngine;
public class Example : MonoBehaviour
{
void Start()
{
// Reported: "Enemies" does not exist in project settings
var enemyLayer = LayerMask.NameToLayer("Enemies");
}
}
using UnityEngine;
public class Example : MonoBehaviour
{
void Start()
{
// "Enemy" is a defined layer in the project
var enemyLayer = LayerMask.NameToLayer("Enemy");
}
}
Quick-fix
This inspection does not provide a dedicated quick-fix. Fix the layer name manually or add the missing layer in Unity project settings.
26 March 2026