Our PlayAnimationByName isn't entirely needed, but it can be a helpful wrapper
for the regular PlayAnimation function

CustomUserWidget.cpp

#include "CustomeUserWidget.h"
voidUCustomUserWidget::NativeConstruct(){FillAnimationsMap();// Call Blueprint Event Construct node
Super::NativeConstruct();}voidUCustomUserWidget::FillAnimationsMap(){AnimationsMap.Empty();UProperty*Prop=GetClass()->PropertyLink;// Run through all properties of this class to find any widget animations
while(Prop!=nullptr){// Only interested in object properties
if(Prop->GetClass()==UObjectProperty::StaticClass()){UObjectProperty*ObjProp=Cast<UObjectProperty>(Prop);// Only want the properties that are widget animations
if(ObjProp->PropertyClass==UWidgetAnimation::StaticClass()){UObject*Obj=ObjProp->GetObjectPropertyValue_InContainer(this);UWidgetAnimation*WidgetAnim=Cast<UWidgetAnimation>(Obj);if(WidgetAnim!=nullptr&&WidgetAnim->MovieScene!=nullptr){FNameAnimName=WidgetAnim->MovieScene->GetFName();AnimationsMap.Add(AnimName,WidgetAnim);}}}Prop=Prop->PropertyLinkNext;}UWidgetAnimation*UCustomUserWidget::GetAnimationByName(FNameAnimationName)const{UWidgetAnimation*const*WidgetAnim=AnimationsMap.Find(AnimationName);if(WidgetAnim){return*WidgetAnim;}returnnullptr;}boolUCustomUserWidget::PlayAnimationByName(FNameAnimationName,floatStartAtTime,int32NumLoopsToPlay,EUMGSequencePlayMode::TypePlayMode,floatPlaybackSpeed){UWidgetAnimation*WidgetAnim=GetAnimationByName(AnimationName);if(WidgetAnim){PlayAnimation(WidgetAnim,StartAtTime,NumLoopsToPlay,PlayMode,PlaybackSpeed);returntrue;}returnfalse;}