Asset definition for a Balloon type used by the ToolGun. Stores a Prefab file, Title and Description, can render a thumbnail by rendering the prefab scene, and provides a small emoji icon for the asset browser.
[AssetType( Name = "Sandbox Balloon", Extension = "bdef", Category = "Sandbox", Flags = AssetTypeFlags.NoEmbedding | AssetTypeFlags.IncludeThumbnails )]
public class BalloonDefinition : GameResource, IDefinitionResource
{
[Property]
public PrefabFile Prefab { get; set; }
[Property]
public string Title { get; set; }
[Property]
public string Description { get; set; }
public override Bitmap RenderThumbnail( ThumbnailOptions options )
{
// No prefab - can't make a thumbnail
if ( Prefab is null ) return default;
var bitmap = new Bitmap( options.Width, options.Height );
bitmap.Clear( Color.Transparent );
SceneUtility.RenderGameObjectToBitmap( Prefab.GetScene(), bitmap );
return bitmap;
}
protected override Bitmap CreateAssetTypeIcon( int width, int height )
{
return CreateSimpleAssetTypeIcon( "🎈", width, height, "#f54248" );
}
}