I have 4 files in my project:
MyUserWidget.cpp
MyUserWidget.h
NewActorComponent.cpp
NewActorComponent.h
In the widget I have a button that generates a number. In the component I have all logic related to player and its location. How do I connect these two .cpp files to get this generated number into a function of the component?
bool UMyUserWidget::Initialize()
{
bool Success = Super::Initialize();
if (!Success)
{
UE_LOG(LogTemp, Warning, TEXT(“Fail”));
return false;
}
if (!ensure(RollDice)) { return false; } // check for nullptrs
RollDice->OnClicked.AddDynamic(this, &UMyNewActorComponent::ChangePos);
UE_LOG(LogTemp, Warning, TEXT("Hi"));
return true;
}
void UNewActorComponent::ChangePos()
{
UE_LOG(LogTemp, Warning, TEXT(“Please work”));
}
This code compiles, but nothing is happening in the output log.
Thank you.