Calling UMG Blueprint animation from C++

So far I have been able to successfully load a blueprint UUserWidget and add it to the viewport via C++ :slight_smile:

Problem: How can I get a UWidgetAnimation from a UUserWidget? There doesn’t seem to be anyway to enumerate these or otherwise obtain of these animation references… (in the editor there is no option to copy a reference to it either). I would like to be able to user UUserWidget->PlayAnimation, but I cannot figure out how to get a UWidgetAnimation to pass to the function.

I am using 4.7.6.

Hi minderaser,

You have to expose a ref in your c++ header file, something like this:



UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Animations)
class UWidgetAnimation* YourAnimationRefName;


Then in your BP (derived from this C++ class) you can easily set an animation: Put a Set YourAnimationRefName node in the graph (make sure Context Sensitive is not checked if this doesn’t come up in the search results), then drag an animation from Animations list of your widget blueprint (check the variables panel, you will find an Animations sub list, you can drag your custom animation from there).

EDIT :
You can also declare a method parameter, maybe I didn’t full understand your question, let me know if this solve your problem!

Hope this helps!

Hi,

You should have your own class derived from UUserWidget in C++ :

Add an UWidgetAnimation property to your c++ source as shown in my previous comment, then in blueprint set it (you could need to check Context Sensitive if the property is not visible in the context menu), now you can set this reference from the blueprint editor, and then call PlayAnimation using your widgetAnimation as parameter.

If this is not helping you, then please give me some more information about your problem and I will try to help you.

Cheers

Another method is to iterate through all properties of the Widget directly in C++, see Get Widget Animation in C++ - UI - Unreal Engine Forums