x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Instanced Widget Component not shown in the Viewport.

Hi everyone.

I have been using code to create a Widget Component to show a Confirm or cancel option in the HUD, and I have set it to the correct Class and the Widget Space to "Screen" value, but I can't seem to be able to display the HUD in the World even though when I check the Actor the Component it's attached correctly and it's using the corresponding Class, and after the component is added if I modify in the Editor anything related to the widget component, it starts to paint it correctly in the viewport, I will post the code down bellow and I hope that someone here can help me out with this issue.

Code:

 void ABuilding::SetupBuildingWidget()
 {
     UWidgetComponent* Widget = NewObject<UWidgetComponent>(this, UWidgetComponent::StaticClass(), TEXT("Building Widget"));
 
     if (!Widget)
     {
         return;
     }
 
     FStringClassReference BuildConfirmReference(TEXT("/Game/UI/BuildBuildingHUD.BuildBuildingHUD_C"));
 
     if (UClass* ConfirmClass = BuildConfirmReference.TryLoadClass<UUserWidget>())
     {
 
         UUserWidget* ConfirmBuildWidget = CreateWidget<UUserWidget>(GetWorld(), ConfirmClass);
 
         Widget->RegisterComponent();
         Widget->SetWidgetSpace(EWidgetSpace::Screen);
         Widget->SetWidgetClass(ConfirmBuildWidget->GetClass());
         Widget->bHiddenInGame = false;
         Widget->SetTwoSided(true);
         Widget->bVisible = true;
         Widget->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale);
 
     }
     else
     {
         Widget->DestroyComponent();
     }
 }

and here is a Screenshot of the Widget has it should appear alt text

And here is what is happening: alt text

Any help with this would be greatly appreciated and another thing is that If I edit any value from the widget from within the PIE, it automatically renders the Widget correctly in the screen. Thank you.

Product Version: UE 4.14
Tags:
more ▼

asked Nov 20 '16 at 11:08 AM in C++ Programming

avatar image

WolfAlvein
23 13 17 21

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question