s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationAssetsResourcesGameresource Extensions
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Assets
Assets

GameResource Extensions

ResourceExtensions can be used to append additional data to existing GameResources without modifying the original class or assets. This is useful for adding additional properties to resources such as Clothing, Surfaces, Models, etc.

You create a ResourceExtension very similarly to any other GameResource, here's an example:

[AssetType( Name = "Clothing Extension", Extension = "extcloth", Category = "Citizen" )]
public class ClothingExtension : ResourceExtension<Clothing, ClothingExtension>
{
    public string CustomName { get; set; }
    public string CustomCategory { get; set; } = "Other";
    public int CostToUnlock { get; set; } = 100;

    protected override Bitmap CreateAssetTypeIcon( int width, int height )
    {
        return CreateSimpleAssetTypeIcon( "iron", width, height );
    }
}

In ResourceExtension<Clothing, ClothingExtension>, Clothing is the resource you are extending.

You can now create your asset extension the same way you would create a new Asset

Once you've set up your extension with the desired values, you can go to the "Extends" tab to specify which Assets this resource should be extending. All specified assets will be able to access this extension.

If "Default" is enabled, then this ResourceExtension will be returned as the default for any Asset without a corresponding extension.

FindForResourceOrDefault( Resource r )

// This will return the ResourceExtension marked as "Default" if the resource doesn't have one
var clothingExtension = ClothingExtension.FindForResourceOrDefault( PlayerHat );

Log.Info( $"The cost of the hat is {clothingExtension.CostToUnlock}" );

FindForResource( Resource r )

// This will return null if the resource doesn't have a ResourceExtension
var clothingExtension = ClothingExtension.FindForResource( PlayerHat );

if ( clothingExtension is not null )
{
  Log.Info( $"The cost of the hat is {clothingExtension.CostToUnlock}" );
}
else
{
  // Handle extension not existing...
}

FindAllForResource( Resource r )

// This will return all ResourceExtension of your type that target the specified resource
// This will NOT return the default unless the default happens to also target the resource
var allExtensions = ClothingExtension.FindAllForResource( PlayerHat );

foreach ( var extension in allExtensions )
{
  Log.Info( $"The cost of the hat is {extension.CostToUnlock}" );
}

FindDefault()

// This will return the ResourceExtension marked as "Default" if one exists
var defaultExtension = ClothingExtension.FindDefault();

Log.Info( $"The default cost is {defaultExtension.CostToUnlock}" );

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2024-12-17. Read it rendered on the official docs.

More in Assets

Assets
Binary Serialization
Citizen Characters
Clothing
Cloud Assets
Custom Assets
File System
First Time Setup
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.