"The Razor @namespace trap"
- C#:
type Hud not found/ can't reference yourPanelComponent. - Razor resolves the wrong type (Sandbox built-in) and you get baffling "no such member" errors.
- Plain
.csclasses without a namespace work;.razorsiblings don't show up beside them.
.razor files do NOT land in the global namespace the way namespace-free plain .cs classes do. They get a RootNamespace / folder-derived namespace.
Related: never name classes after Sandbox built-ins (PlayerController, etc.). A global-namespace name may compile, but razor resolves Sandbox.* first.
Scene/bootstrap JSON that references types by short name also expects some bootstrap classes to stay namespace-free — keep those specific entry types namespace-free if your scene already binds that way. (needs verification) against your .scene type strings.
In every .razor:
@namespace YourGameIn Assembly.cs (or equivalent):
global using YourGame;Then C# and other razor files can see Hud, InventoryPanel, etc.
Rename player/camera/inventory-ish classes away from Sandbox API names before you fight phantom member errors.
The Razor generator emits classes into a project-derived namespace unless you override it. global using puts that namespace in scope for the rest of the game assembly so panel types behave like your other gameplay types. Explicit @namespace also stops accidental collisions with Sandbox.UI names.