Skip to main content

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

PropertyTypeRestrictionsDescription
IdstringRequired
Length: 1 - 256
Pattern: ^[\w\.\-]+$
The unique identifier of the resource.
Altstring?Max length: 256Optional 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 Content with CopyToOutputDirectory and CopyToPublishDirectory in the .csproj (the same way as the mobro_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

PropertyTypeRestrictionsDescription
IdstringSee aboveThe unique identifier of the icon.
Altstring?See aboveOptional alternative text displayed if the icon can't load.
RelativeFilePathsIDictionary<IconSize, string>RequiredThe 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

PropertyTypeRestrictionsDescription
IdstringSee aboveThe unique identifier of the image.
Altstring?See aboveOptional alternative text displayed if the image can't load.
RelativeFilePathstringRequired
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);