IResource
A file-based item, such as an icon or an image.
Every resource type implements this interface. Resources can be referenced by other items (e.g. as the icon of
a Category) or used as the value of a metric of type CoreMetricType.Icon or CoreMetricType.Image.
See also: Registering Items
Properties
| Property | Type | Restrictions | Description |
|---|---|---|---|
| Id | string | Required Length: 1 - 256Pattern: ^[\w\.\-]+$ | The unique identifier of the resource. |
| Alt | string? | Max length: 256 | Optional alternative text displayed if the resource can't load. |
Resource Files
- File paths are relative to the plugin's directory, and the files must exist when the resource is registered.
- Files must be located inside the plugin's directory. Resources pointing outside of it are not registered.
- Make sure the files are part of the published plugin, e.g. by adding them as
ContentwithCopyToOutputDirectoryandCopyToPublishDirectoryin the.csproj(the same way as themobro_plugin_config.json).
Specific Types
Icon
A small graphic image.
An icon may consist of multiple image files (e.g., PNG, JPEG) for different sizes.
tip
Best Practice: For the best visual result, always provide a single SVG file whenever possible.
Properties
| Property | Type | Restrictions | Description |
|---|---|---|---|
| Id | string | See above | The unique identifier of the icon. |
| Alt | string? | See above | Optional alternative text displayed if the icon can't load. |
| RelativeFilePaths | IDictionary<IconSize, string> | Required | The relative paths to the image files for all supported sizes. |
Icon Sizes
The IconSize enum defines the available sizes: Small, Default and Large.
Example
var icon = MoBroItem
.CreateResource()
.WithId("coin_icon")
.WithAlt("Coin")
.Icon()
.AddFromRelativePath("Resources/Icons/coin.svg") // IconSize.Default
.Build();
_mobro.Register(icon);
Image
A larger image or picture.
Unlike an Icon, an image consists of a single file and does not support multiple sizes.
Properties
| Property | Type | Restrictions | Description |
|---|---|---|---|
| Id | string | See above | The unique identifier of the image. |
| Alt | string? | See above | Optional alternative text displayed if the image can't load. |
| RelativeFilePath | string | Required Max length: 128 | The relative path to the image file. |
Example
var image = MoBroItem
.CreateResource()
.WithId("album_cover")
.WithoutAlt()
.Image()
.FromRelativePath("Resources/Images/cover.png")
.Build();
_mobro.Register(image);