Download

Trying to figure out this UMG Render Opacity issue

Hi guys!

For some reason, my UScrollBox and its children are disappearing when I call an animation throug a PlayAnimation, where the canvas Render Opacity is configured, going from 0 to 1: apparently, the UScrollBox and its children opacity were inversed, going from 1 to 0 instead. Any clues?

Im using C++ and Im not using any animation where the UScrollBox’s opacity is changed.

Here is the code where I bind the animations and the callbacks:

void UIMDesigns_SearchWidget::NativeConstruct()
{
	Super::NativeConstruct();

	bIsFocusable = true;

	PlayerController = GetWorld()->GetFirstPlayerController<AIMDesigns_SearchController>();

	if(PlayerController.IsValid())
	{
		HUDPtr = PlayerController->GetHUD<AIMDesigns_SearchHUD>();

		if (HUDPtr.IsValid())
		{
			AIMDesigns_SearchHUD* HUD = HUDPtr.Get();

			if (!OnFadeInEffectFinished.IsBound())
			{
				OnFadeInEffectFinished.BindUFunction(HUD, FName("EnableButtons"));

				BindToAnimationEvent(FadeIn, OnFadeInEffectFinished, EWidgetAnimationEvent::Finished);
			}

			if (!OnFadeOutEffectStarted.IsBound())
			{
				OnFadeOutEffectStarted.BindUFunction(HUD, FName("DisableButtons"));

				BindToAnimationEvent(FadeOut, OnFadeOutEffectStarted, EWidgetAnimationEvent::Started);
			}

			if (!OnFadeOutEffectFinished.IsBound())
			{
				OnFadeOutEffectFinished.BindUFunction(PlayerController.Get(), FName("LoadMainMenuMap"));

				BindToAnimationEvent(FadeOut, OnFadeOutEffectFinished, EWidgetAnimationEvent::Finished);
			}	

			if(ensureMsgf(BackToMenuButton, 
				TEXT("There is no BackToMenuButton in the widget, please verify its existence.")))
			{
				SetUpButton(BackToMenuButton, ESearchProcessButtons::BackToMenu);
			}

			if (ensureMsgf(ResetButton, 
				TEXT("There is no ResetButton in the widget, please verify its existence.")))
			{
				SetUpButton(ResetButton, ESearchProcessButtons::Reset);
			}

			if (ensureMsgf(SaveButton, 
				TEXT("There is no SaveButton in the widget, please verify its existence.")))
			{
				SetUpButton(SaveButton, ESearchProcessButtons::Save);
			}

			if (ensureMsgf(SearchButton, 
				TEXT("There is no SearchButton in the widget, please verify its existence.")))
			{
				SetUpButton(SearchButton, ESearchProcessButtons::Search);
			}

			if (ensureMsgf(SearchText,
				TEXT("There is no SearchText in the widget, please verify its existence.")))
			{				
				SearchText->SetIsReadOnly(false);
				SearchText->SetIsEnabled(false);
			}

			if (ensureMsgf(SearchScrollBox, 
				TEXT("There is no SearchScrollBox in the widget, please verify its existence.")))
			{					
				SearchScrollBox->SetAlwaysShowScrollbar(true);
				SearchText->SetIsEnabled(false);
			}

			PlayAnimation(FadeIn); //The culprit is here 			
		}
	}	

}

Here is the code where I add the UWidgets to th UScrollBox:

void AIMDesigns_SearchController::OnSearchWidgetCreated(UIMDesigns_SearchWidget* Widget)
{
	if(Widget)
	{
		SearchWidget = Widget;

		if (IFileManagementUtils::FileExists(FILE_NAME, FILE_DIRECTORY))
		{
			//GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, TEXT("A database was found."));

			UScrollBox* ScrollBox = SearchWidget->GetSearchScrollBox();

			IFileManagementUtils::LoadTextDataFrom(FILE_NAME, FILE_DIRECTORY, FileData);

			if(FileData.Num() > 0)
			{
				//GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, TEXT("The database isn't empty."));

				for (FString Line : FileData)
				{
					//GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, *Line);

					TWeakObjectPtr<UEditableText> Text = NewObject<UEditableText>(
						this,
						UEditableText::StaticClass()
					);
					Text->SetVisibility(ESlateVisibility::Visible);					
					Text->SelectAllTextWhenFocused = true;
					Text->SetText(FText::FromString(Line));

					ScrollBox->AddChild(Text.Get());					

					EditableTextArr.Add(Text);
				}
			}
		}
	}

}

And here is a video:

Also, apparently, something is messing up the UScrollBox opacity during the Canvas opacity animation: the UScrollBox opacity goes from 0 to 1 (it reaches 1 at 0.5 seconds) and then from 1 to 0., here is the video 2021 07 23 23 34 07 - YouTube. I still don’t know why =S

Any help will be appreciated!

Thanks!