M2Extras: Skins System

Outlining a basic example system for how to make UI skins

We have a M2Extra plugin (disabled by default) that provides an example of how to add a skins system to your project, that allows you to set some "skin data" that can be reacted to by your UI.

The example widget when the skin is set to the first example skin. The background color is black, and the font is white
The example widget when the skin is instead set to the second example skin. The background color has changed to white, and the font is now black (this can be previewed in the editor window)

NOTE: This is just an example of how one could make a skins system entirely using Blueprints, and may not be fit for every purpose. Feel free to use this as reference, or modify it for your project as you see fit!

If you want to enable the plugin, you can find it in Plugins -> Installed -> MSquared -> M2 Extras: Skins System

How to configure a skin

Using Making DataAsset classes, we have made a BP_SkinDataAsset class, that extends M2_DataAsset.

In this, we can create instanced object properties (see "Instanced Objects" in Blueprints) that contain the various skin settings we want to be associated with the skin (in the example, we have made a single BP_ExampleSkinSetting which has 2 colours: one for the background, and one for the font)

With the data asset class made, we can make data assets from that base class, and modify the values for the settings we have created. These will be the different "skins".

Searching the skin asset

To search the skin asset for the right instanced object, we have added some helpers: GetSettingByClass and GetAllSkinSettings. With these, a user can search for e.g. our BP_ExampleSkinSetting from the asset.

How to use the skin

The Skin Manager

For the skins system to be used in your level, first you will need to place the skin manager into your level (BP_SkinManager).

This Skin Manager is the actor responsible for tracking the currently used SkinAsset.

The Skin Function Library

BPFL_Skins contains helper functions that enable a user (e.g. a widget) to e.g. get the current skin, or listen to updates:

  • GetSkinManager: Returns the skin manager.

    • NOTE: It must be manually added to the level for this to work.

  • GetCurrentSkinAsset: Returns the current skin asset being used.

    • If this is called in the editor (e.g. when previewing widgets), this will return the default value in the BP_SkinManager), using GetCDO

  • ListenToSkinUpdates: Will trigger a delegate when we have a skin, and any time the skin is updated. Can be used to initialize and also listen to updates.

An example in action (WBP_ExampleSkinnedWidget)

WBP_ExampleSkinnedWidget is the example widget packaged in M2Extras: Skins System. It shows how to listen to the skin asset correctly using the helper functions, both in Design time (where it will use the skin manager's default value), and at runtime, where it will use the latest value in the skin manager

Last updated

Was this helpful?