I found that when I use a function in the C++, it didn’t work.The function is under the question.The function is in a UMG,and it is a main UMG,it contain other UMG.The function is used to be change a UMG button and chang the music of the game,the UMG is contained by the main UMG.I found I can change the music ,but I couldn’t chang the button.I couldn’t set the button is enabled.I do not know why!It confused me.
void UWSPVPMainPage::EnableWaveButton(bool IsWaveEnd)
{
SetAccack->StartAttackBtn->SetIsEnabled(true);
if (SetAccack->AttackSounds == nullptr)
{
SetAccack->AttackSounds->SetSound(SetAccack->AttackSound);
UE_LOG(LogTemp, Error, TEXT("AttackSounds is nullptr!"));
return;
}
SetAccack->AttackSounds->Stop();
if (IsWaveEnd)
{
SetAccack->AttackSounds->SetSound(SetAccack->PiceSound);
}
else
{
SetAccack->AttackSounds->SetSound(SetAccack->AttackSound);
}
SetAccack->AttackSounds->Play(0);
}