I want to replace a sequence of texture images used in a Slate Widget for an animated loading screen image by a UI Material using a flipbook texture. I am using the MoviePlayer API for the Loading Screen to make this async.
The Material looks as follows and works perfectly in UMG:
The Slate Brush is defined as follows
struct HENRYLOADINGSCREEN_API FFlipBookBrush : public FSlateBrush, public FGCObject
{
FFlipBookBrush(const FName InMaterialName, const FVector2D& InImageSize)
: FSlateBrush(ESlateBrushDrawType::Image, InMaterialName, FMargin(0), ESlateBrushTileType::NoTile, ESlateBrushImageType::FullColor, InImageSize, FLinearColor(1, 1, 1, 1))
{
SetResourceObject(LoadObject<UObject>(NULL, *InMaterialName.ToString()));
}
virtual void AddReferencedObjects(FReferenceCollector& Collector)
{
if (UObject* CachedResourceObject = GetResourceObject())
{
Collector.AddReferencedObject(CachedResourceObject);
}
}
};
And the SImage using the material is created as follows (still hardcoded name for testing)
FlipBookBrush = MakeShareable(new FFlipBookBrush(FName(/Game/Henry/UI/Flipbook-material/M_ChickenFlipbook.M_ChickenFlipbook), FVector2D(96, 96)));
FlipBookMat = SNew(SImage).Image(FlipBookBrush.Get());
When I add this to the Widget, it does not work as expected. It does not matter whether I derive the brush from FSlateBrush or from FSlateMaterialBrush. In both cases:
- For a loading screen loaded at game load time (module load), nothing is rendered at all.
- For an In Game loading screen at level change only one of the images (not the first one) is shown frozen and no animation happens at all.
I almost get the impression, that using Flipbook materials with Time node is not a supported thing for Slate Widgets running on a separate thread with MoviePlayer, and that I must keep going on with a series of Texture Images updated using OnPaint() override.
Is my assumption correct or am I still missing something here?