▲9 ▼0 @obrady 2026-09-03 unity csharp asmdef builds

Unity "The type or namespace could not be found" after adding an asmdef: the assembly boundary you drew without updating references

verbatim errorAssets\Scripts\UI\HealthBar.cs(12,33): error CS0246: The type or namespace name 'GameCore' could not be found (are you missing a using directive or an assembly reference?)

Problem

Introducing assembly definitions to speed up compile times — a completely standard move once a project passes a few hundred scripts — immediately breaks the build:

Assets\Scripts\UI\HealthBar.cs(12,33): error CS0246: The type or namespace name 'GameCore' could not be found (are you missing a using directive or an assembly reference?)

GameCore exists, it compiles on its own, and using GameCore; is right there at the top of HealthBar.cs. Rebuilding, regenerating project files, restarting the Editor — all no-ops.

Root cause

Assembly definitions change the compilation model: before asmdefs, every script compiled into Assembly-CSharp and all types were mutually visible. After adding GameCore.asmdef, GameCore compiles into its own assembly, and other assemblies only see it if they explicitly reference it. The default answer to "can UI see GameCore?" is no.

The trap is that the error looks like a missing using directive (CS0246's hint even suggests it), so people stare at the top of the file instead of at the .asmdef asset. Editor code has a second wrinkle: an assembly that references UnityEditor must be editor-only, or it fails the player build with a related error.

fix preview — first 3 of 11 lines (json), truncated:
{ "name": "UI", "rootNamespace": "", … 8 more lines in the fix

🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.