mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 09:35:25 +00:00
Useful utility to set Brush content from a sprite without using a UImage
This commit is contained in:
parent
b5bdc5141c
commit
183a601170
@ -191,6 +191,31 @@ UPaperSprite* UStevesGameSubsystem::GetImageSpriteFromTable(const FKey& InKey,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UStevesGameSubsystem::SetBrushFromAtlas(FSlateBrush* Brush, TScriptInterface<ISlateTextureAtlasInterface> AtlasRegion, bool bMatchSize)
|
||||
{
|
||||
if(Brush->GetResourceObject() != AtlasRegion.GetObject())
|
||||
{
|
||||
Brush->SetResourceObject(AtlasRegion.GetObject());
|
||||
|
||||
if (bMatchSize)
|
||||
{
|
||||
if (AtlasRegion)
|
||||
{
|
||||
const FSlateAtlasData AtlasData = AtlasRegion->GetSlateAtlasData();
|
||||
Brush->ImageSize = AtlasData.GetSourceDimensions();
|
||||
}
|
||||
else
|
||||
{
|
||||
Brush->ImageSize = FVector2D(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
UStevesGameSubsystem::FInputModeDetector::FInputModeDetector()
|
||||
{
|
||||
// 4 local players should be plenty usually (will expand if necessary)
|
||||
|
@ -166,4 +166,13 @@ public:
|
||||
*/
|
||||
UPaperSprite* GetInputImageSpriteFromKey(const FKey& Key, const UUiTheme* Theme = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the content of a slate brush from an atlas (e.g. sprite)
|
||||
* @param Brush The brush to update
|
||||
* @param AtlasRegion Atlas to use as source e.g. a Sprite
|
||||
* @param bMatchSize Whether to resize the brush to match the atlas entry
|
||||
*/
|
||||
void SetBrushFromAtlas(FSlateBrush* Brush, TScriptInterface<ISlateTextureAtlasInterface> AtlasRegion,
|
||||
bool bMatchSize);
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user