M2Extras: Skins System
Outlining a basic example system for how to make UI skins
Last updated
Outlining a basic example system for how to make UI skins
Last updated
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.
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
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".
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.
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
.
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.
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