FindObjectOfType is obsolete: use FindFirstObjectByType or FindAnyObjectByType

Object.FindObjectOfType is obsolete in Unity 6. Which replacement to pick, FindFirstObjectByType or the faster FindAnyObjectByType, and how to keep including inactive objects.

Status
Obsolete since Unity 6.0 · Scripting
Old
Object.FindObjectOfType
New
Object.FindFirstObjectByType, Object.FindAnyObjectByType
Checked
2026-10-05, against the sources below

What changed

Object.FindObjectOfType is obsolete in Unity 6. Unity split it in two so you can say what you need. FindFirstObjectByType returns the same object the old call did. FindAnyObjectByType returns any matching object and is faster, because it does not have to work out which one is first.

If you only ever have one instance, such as a GameManager, FindAnyObjectByType is the better choice. The checker on this site uses FindFirstObjectByType, because it is the replacement that cannot change your game's behaviour.

The old includeInactive bool becomes an enum: pass FindObjectsInactive.Include to keep finding disabled objects.

Before and after

Before
C#
var manager = FindObjectOfType<GameManager>();
var menu = FindObjectOfType<PauseMenu>(true);
After
C#
var manager = FindFirstObjectByType<GameManager>();
var menu = FindFirstObjectByType<PauseMenu>(FindObjectsInactive.Include);

// Faster when any instance will do:
var anyManager = FindAnyObjectByType<GameManager>();

Fix it automatically

Paste a script into the Unity 6 Script Upgrade Checker and it applies this rename for you, along with the other safe fixes for your target version.

Open this example in the checker

Questions

Is FindAnyObjectByType safe when there are several matches?
It returns one of them, and which one is not guaranteed; it can differ between runs and platforms. Use it when there is only ever one instance, such as a GameManager. When several exist and you need a predictable one, keep an explicit reference instead.
Can I call these methods every frame?
Avoid it. Both search every loaded object of that type. Call them once in Awake or Start and keep the result in a field, or have objects register themselves with a manager when they spawn.

Sources

Related Unity 6 changes

Every Unity 6.x change, by version