- Type
- UMG widget (C++)
- Engine
- Unreal Engine 5.8
- Modules
- UMG, Slate, SlateCore
- Status
- Plugin pending on Fab
The problem
A Retainer Box draws its children to a render target and applies an Effect Material. That material is a plain material pointer, and UMG only offers a Material Track for brush properties. So the material of an Image can be animated, but the one on a Retainer Box cannot.
Sharing one dynamic instance
The subclass adds a brush and, in SynchronizeProperties, points it at GetEffectMaterial(). That call returns the Material Instance Dynamic the Slate widget is actually drawing with. Pointing the brush at the asset instead makes the track animate a second instance that nobody renders, which is why nothing moves on screen.
C++ (excerpt) void UMyAnimatableRetainerBox::SynchronizeProperties() { Super::SynchronizeProperties(); // Same dynamic instance the Retainer Box draws with, not the source asset. Brush.SetResourceObject(GetEffectMaterial()); }Using it
Drop the widget from the Palette, put the children inside and set the Effect Material and its texture parameter. In Animations, add the widget, pick Brush › Brush Material and keyframe any scalar or vector parameter.
What changed for the plugin
- Deprecated access
- uses IsRetainRendering() instead of the deprecated field
- Designer preview
- uses the engine flag Show Effects In Designer instead of a duplicate property
- Runtime material swap
- new Blueprint functions, because SetEffectMaterial is not virtual
- Palette
- its own category
Next iteration
- Release on Fab with example content.
- Test in a Blueprint-only project.
- Decide on support for earlier 5.x versions.
Problems solved
- Packaging failed
- a type was only forward-declared and the editor build passed by luck; fixed with the missing include
- Animation changed nothing
- the brush pointed at the asset, not at the shared instance
- No effect in the Designer
- retained rendering is off at design time unless the flag is set
Cost
- Extra render target
- worth it for a group of widgets sharing one effect; a single Image with a material is cheaper