FindObjectOfType Is Obsolete in Unity 6 — The Complete Migration Cheatsheet
If you’ve opened a project in Unity 6 (or 2023) and your Console lit up with warnings like
“Object.FindObjectOfType is obsolete”, you’re not alone — it’s one of the most-reported
upgrade warnings. The good news: the migration is mechanical, and once you know the mapping it
takes minutes. This is the complete cheatsheet.
What changed, and why
Unity retired the old object-finding pair — FindObjectOfType and FindObjectsOfType — and
replaced them with a more explicit trio:
FindFirstObjectByTypeFindAnyObjectByTypeFindObjectsByType
The motivation is clarity of intent. The old methods hid two important decisions: do you need the first match or will any match do, and do you want inactive objects included? The new API forces you to say so — which also lets Unity skip work you don’t need (like sorting).
The cheatsheet
| Old (obsolete) | New (Unity 6) |
|---|---|
FindObjectOfType<T>() | FindFirstObjectByType<T>() (direct equivalent) or FindAnyObjectByType<T>() (faster, if any instance is acceptable) |
FindObjectsOfType<T>() | FindObjectsByType<T>(FindObjectsSortMode.None) |
FindObjectsOfType<T>(true) | FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None) |
First vs. Any — which one?
FindFirstObjectByType<T>()returns the first match in a deterministic order. Use it as the drop-in replacement when you previously relied onFindObjectOfTypereturning a stable result.FindAnyObjectByType<T>()returns any match and is faster, because it doesn’t have to find the “first” — it stops at the first thing it sees. Use it when you genuinely don’t care which instance you get (e.g. fetching a unique manager/singleton).
The new enum parameters
FindObjectsByType takes explicit enums where the old API used a bool and an implicit sort:
FindObjectsInactive—.Includeor.Exclude. The oldFindObjectsOfType(true)meant “include inactive”, which is nowFindObjectsInactive.Include. Default behaviour (no bool) excluded inactive objects.FindObjectsSortMode—.Noneor.InstanceID. The oldFindObjectsOfTypealways sorted results by InstanceID. If you don’t actually need that ordering, passFindObjectsSortMode.None— it’s considerably faster. Only use.InstanceIDif your code depended on the old sorted order.
Practical rule: replace
FindObjectsOfType<T>()withFindObjectsByType<T>(FindObjectsSortMode.None)unless you have a specific reason to keep the sort. Most code never relied on it.
Migrating without breaking older Unity versions
If your codebase or package has to support more than one Unity version, here’s the key fact: the new methods were backported to older versions (≥ 2020.3, 2021.3, 2022.2, 2023, 6000), even though the obsolete warning only fires in Unity 6 and 2023.
That means you can safely adopt FindAnyObjectByType / FindObjectsByType today, even in a
2021.3 LTS project, and it will compile everywhere — you don’t need #if UNITY_6000_0_OR_NEWER
fences for the common cases. Migrate forward, not sideways.
Don’t just swap — reconsider the call
While you’re touching this code, remember the warning the docs have always carried: these
methods are slow, and you should not call them every frame. A swap from FindObjectOfType
in Update() to FindAnyObjectByType in Update() is still a per-frame scene search.
If you’re reaching for these inside Update, cache the reference in Awake/Start, or use a
proper singleton/registry pattern. The migration is a good moment to fix the real cost, not
just silence the warning.
Let PerfLint find every call site for you
A project of any size can have dozens of these scattered across scripts, and the warnings don’t
tell you which ones live in hot paths. PerfLint for Unity scans your
project locally and reports every deprecated/removed API — including FindObjectOfType —
located to the exact line, with the correct replacement for your Unity version
(MIG.FindObjectOfType). For safe mechanical renames like this one, it can apply a
compile-verified one-click migration that automatically rolls back if the build breaks.
Run a free scan →
FAQ
What replaces FindObjectOfType in Unity 6?
FindFirstObjectByType<T>() as a direct replacement, or FindAnyObjectByType<T>() if any
matching instance is acceptable (it’s faster).
What replaces FindObjectsOfType (the plural)?
FindObjectsByType<T>(FindObjectsSortMode.None). Add FindObjectsInactive.Include as the first
argument if you need inactive objects (the old FindObjectsOfType(true)).
Will switching break my Unity 2021/2022 project? No. The new methods are backported to 2020.3/2021.3/2022.2 and newer, so the migrated code compiles on older versions too. Only the obsolete warning is limited to Unity 6 and 2023.
Is FindAnyObjectByType always better than FindFirstObjectByType?
It’s faster but non-deterministic about which instance you get. Use it only when any match is
acceptable; otherwise use FindFirstObjectByType.
Rule reference: MIG.FindObjectOfType