Linker error using UWidgetAnimation::BindToAnimationFinished

Hi,

I’m really bugged by a LNK2019 happening trying to use UWidgetAnimation::BindToAnimationFinished.

I do have the UMG modules specified in my Build.cs:

public class Theseus : ModuleRules
{
	public Theseus(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
		PublicDependencyModuleNames.AddRange(new string[] { "UMG", "Slate", "SlateCore" });
		PrivateDependencyModuleNames.AddRange(new string[] { "GameplayTasks", "AIModule", "NavigationSystem" });
		PrivateDependencyModuleNames.AddRange(new string[] { "Niagara" });
	}
}

I do have the right includes in my widget class (derived from UUserWidget):

#include "Animation/WidgetAnimation.h"
#include "Blueprint/UserWidget.h"

And this is how I’m trying to bind a UFUNCTION with BindToAnimationFinished:

FWidgetAnimationDynamicEvent MyAnimationEvent;
MyAnimationEvent.BindDynamic(this, &UWidgetInventory::BindingTest);
GetAnimationByName(TEXT("FadeOutMessages"))->BindToAnimationFinished(this, MyAnimationEvent);

However, no matter how I clean my build and rebuild, this is what I get:

error LNK2019: unresolved external symbol "public: void __cdecl UWidgetAnimation::BindToAnimationFinished(class UUserWidget *,class FWidgetAnimationDynamicEvent)" (?BindToAnimationFinished@UWidgetAnimation@@QEAAXPEAVUUserWidget@@VFWidgetAnimationDynamicEvent@@@Z) referenced in function "protected: virtual void __cdecl UWidgetInventory::NativeConstruct(void)" (?NativeConstruct@UWidgetInventory@@MEAAXXZ)

I’ve also tried to use a plain pointer to a specified UWidgetAnimation (ie. not a pointer returned by my function GetAnimationByName) to no avail.

I beg your help, this is driving me crazy!

Thank you,

f

The WidgetAnimation.h not have UMG_API in class or function(BindToAnimationFinished).

so, You can not Use It In Your Source Module, Only Change It.

try
class UMG_API UWidgetAnimation : public UMovieSceneSequence
or
UMG_API void BindToAnimationStarted(UUserWidget* Widget, FWidgetAnimationDynamicEvent Delegate);

I ran into the same issue and ended up here.

Looks like UWidgetAnimation::BindToAnimationFinished is explicitly not exported from the UMG module. However, UUserWidget::BindToAnimationFinished is. My guess is they want to use the User Widget wrapper instead of going directly to the WidgetAnimation version of that function.

Assuming you have “UMG” added to your module dependencies, this should fix the issue for you if the code is in a UUserWidget derived class:

FWidgetAnimationDynamicEvent MyAnimationEvent;
MyAnimationEvent.BindDynamic(this, &UWidgetInventory::BindingTest);
BindToAnimationFinished(GetAnimationByName(TEXT("FadeOutMessages")), MyAnimationEvent);
1 Like