Retainer Box: Using animation timeline to adjust effect material parameters not working?

I watched this video (Using Simple Generic Materials to Improve UI Performance | Unreal Fest 2024) recently and was interested in their method of using materials and material functions to animate and transform UI.

Most of what they demonstrated is doable using material functions from the UIMaterialLab project, but one thing they did do was create a custom retainer box called an “animated retainer box” which adds a Brush property that’s auto-synced to the effect material so that you can animate the material’s properties in the animation timeline (via Brush.Brush Material).

I think I correctly implemented something similar for myself + also implemented the toggle to preview the effect material in designer, but one thing that isn’t working for me is the animation timeline. If I adjust the parameters of the retainer box material in the animation timeline, none of it shows both in design mode and in gameplay. You can see here what should happen with the timeline.

Is there something I’m not setting up correctly in the animated retainer box class? I make sure to create a dynamic material instance on pre-construct, but…

The .h file:

UCLASS()
class BUGNAUTS_API UAnimatableRetainerBox : public URetainerBox
{
	GENERATED_BODY()

public:

	UPROPERTY(EditAnywhere, Category = "Appearance")
	FSlateBrush Brush;

	UPROPERTY(EditAnywhere, Category = "Effect")
	bool ShowEffectsInDesigner = false;

protected:

	//~ Begin UWidget interface
	virtual void SynchronizeProperties() override;
	//~ End of UWidget interface
};

The .cpp file:

void UAnimatableRetainerBox::SynchronizeProperties()
{
	Super::SynchronizeProperties();

	PRAGMA_DISABLE_DEPRECATION_WARNINGS
	Brush.SetResourceObject(EffectMaterial);							
	MyRetainerWidget->SetRetainedRendering(IsDesignTime() ? ShowEffectsInDesigner : bRetainRender);
	PRAGMA_ENABLE_DEPRECATION_WARNINGS
}
1 Like

Nevermind, can’t tell if closing and opening Unreal was what fixed it, or if rebuilding the project was what fixed it, but it’s working now.

One thing to note is that I did change back Brush.SetResourceObject(EffectMaterial); to Brush.SetResourceObject(GetEffectMaterial());.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.