the symptom, in your words

"[GameResource] is obsolete: declare custom resources with [AssetType]"

✓ verified on 26.07.15a
lane Building UIposted

▸ SYMPTOM

  • A GameResource subclass compiles, but the build reports CS0618: 'GameResourceAttribute' is obsolete: 'Use AssetType instead'.
  • CS0618 is a warning, so a plain dotnet build still exits green and the message is easy to miss.
  • The warning only becomes a hard failure if the project treats warnings as errors, or a review gate demands zero warnings.

▸ CAUSE

The old attribute used a positional constructor:

snippet
[GameResource( "Spell", "spell", "A castable spell" )]
public class SpellDefinition : GameResource { }

GameResourceAttribute is now marked obsolete in favor of AssetTypeAttribute. The compiler keeps honoring it for one more cycle, so nothing breaks yet, but the warning stands until you migrate.

▸ FIX

Swap the attribute for [AssetType] and pass named properties instead of positional arguments:

snippet
[AssetType( Name = "Spell", Extension = "spell", Category = "My Category" )]
public class SpellDefinition : GameResource { }

The properties on Sandbox.AssetTypeAttribute (from Sandbox.Engine.xml) are Name, Extension, Category, TargetType, Flags, and IconColor.

There is no Icon property. The old [GameResource( ..., Icon = "auto_awesome" )] named argument does not carry over, so drop it during the swap. A headless dotnet build reports zero warnings and zero errors once the attribute is replaced.

▸ WHY IT WORKS

Only the declaring attribute changes. The type still derives from GameResource, still produces its .ext file, and is still returned by ResourceLibrary.GetAll<T>(). [AssetType] is the current name for the same registration, so moving to it clears CS0618 without touching how the resource loads or how you query it.

Verified on engine 26.07.15a: seen in a real project.
s&box moves fast; an undated fix is a liability. Spot a stale detail?
changelog
  • Published

Want to know when new guides or fixes drop? Join the community to help build this out. Report gotchas, flag outdated fixes, or just lurk.

Join the Discord