Home / Unity / U20

Unity error: CS0246: The type or namespace name '<name>' could not be found (are you missing a using directive or an assembly reference?) — cause and fix

The script references a type or namespace that does not exist: misspelled class name, miss

ID
U20
Engine
Unity
Verification
官方文档引用
Frequency
未公开

Original message (verbatim)

CS0246: The type or namespace name '<name>' could not be found (are you missing a using directive or an assembly reference?)

Placeholders such as %s / %d are kept verbatim from the engine source and are not replaced with concrete values.

Trigger

The script references a type or namespace that does not exist: misspelled class name, missing using directive, unreferenced assembly, or the file not included in compilation, so Assembly-CSharp fails to compile in the editor.

Typical cause

The Roslyn compiler cannot find the type in the referenced assemblies and emits CS0246; the script does not compile and the console reports an Assembly-CSharp compile error.

Step-by-step fix

  1. Check the type and namespace spelling and add the missing using directive.
  2. Confirm the dependency assembly or package is installed and referenced by the current assembly.
  3. Check the asmdef compilation scope of the script's folder so the file enters the correct assembly.

Source links

Per-entry sources and capture date are listed at /sources#U20.

Related errors

Related Unity errors

Need an offline quick-reference checklist?

Atlas error library Pro pack: 123 error references (110 single + 13 merged) plus a quick-fix guide, $19 one-time purchase, delivered as electronic files.

View Pro pack / order

Back to the all-errors index Checkout and buy the Pro pack — $19.00