UNT0040 GameObject.isStatic is editor-only

January 28, 2026 ยท View on GitHub

GameObject.isStatic is only usable in the Editor. In builds, it always returns false. Use editor-only code or editor callbacks like OnValidate/Reset when accessing isStatic.

Examples of patterns that are flagged by this analyzer

using UnityEngine;

class Camera : MonoBehaviour
{
    void Start()
    {
        if (gameObject.isStatic)
        {
            // This will never execute in builds
        }
    }
}

Solution

Use it within editor-only Unity messages like OnValidate or Reset:

using UnityEngine;

class Camera : MonoBehaviour
{
    void OnValidate()
    {
        if (gameObject.isStatic)
        {
            // This is acceptable because OnValidate is editor-only
        }
    }
}