codeAPI Reference
s&box ScriptedEntity: Custom entity GameResource
ScriptedEntity GameResource API Reference
ScriptedEntity is a GameResource that defines a spawnable entity with a prefab, used by the spawn menu to create custom entities.
Type Signature
CSHARP
[AssetType(Name = "Sandbox Entity", Extension = "sent", Category = "Sandbox", Flags = AssetTypeFlags.NoEmbedding | AssetTypeFlags.IncludeThumbnails)]
public class ScriptedEntity : GameResource, IDefinitionResource
{
[Property]
public PrefabFile Prefab { get; set; }
[Property]
public string Title { get; set; }
[Property]
public string Description { get; set; }
[Property]
public string Category { get; set; }
[Property]
public bool IncludeCode { get; set; }
[Property]
public bool Developer { get; set; }
public override Bitmap RenderThumbnail(ThumbnailOptions options);
protected override Bitmap CreateAssetTypeIcon(int width, int height);
public override void ConfigurePublishing(ResourcePublishContext context);
}Properties
- PrefabFile Prefab { get; set; } - The prefab to spawn when this entity is created.
- string Title { get; set; } - Display name in the spawn menu.
- string Description { get; set; } - Description shown in the spawn menu.
- string Category { get; set; } - Category name for grouping in spawn menu (e.g., "Chair", "Weapon", "Npc", "World"). Blank places it under "Other".
- bool IncludeCode { get; set; } - If true, includes code when publishing. Enable if the entity uses custom code.
- bool Developer { get; set; } - If true, only appears in spawn menu when running in editor. Use for test/debug entities.
Methods
RenderThumbnail(ThumbnailOptions options)
Renders the prefab as a thumbnail image for the asset browser.CreateAssetTypeIcon(int width, int height)
Creates the asset type icon (📦) for the editor.ConfigurePublishing(ResourcePublishContext context)
Configures publishing settings. Disables publishing if prefab is missing. Sets IncludeCode based on the property.Usage
Create a .sent file to define a custom spawnable entity:
CSHARP
[AssetType(Name = "Sandbox Entity", Extension = "sent", Category = "Sandbox")]
public class MyCustomEntity : ScriptedEntity
{
[Property]
public PrefabFile Prefab { get; set; }
[Property]
public string Title { get; set; } = "My Custom Entity";
[Property]
public string Description { get; set; } = "A custom entity for my game";
[Property]
public string Category { get; set; } = "Props";
[Property]
public bool IncludeCode { get; set; } = true;
}Notes
- File extension is .sent
- Implements IDefinitionResource for metadata
- Thumbnail is rendered from the prefab scene
- Developer entities are hidden in published games
- Category property controls spawn menu organization
Was this helpful?