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"

Change UUserWidget Height and Width

I am creating a 3D pop up UMG system and am running into a bit of a problem trying to set up a sorta custom resize of the layout in C++. I have gotten everything working like spawning the 3D UMG widget and component and have all my widgets inside a CanvasPanel and ScaleBox and am using the SetSize() function to resize my images and borders inside that Panel. My problem is that I cant seem to rezise the main UserWidget's size. In the actual engine changing the Preview Size to Custom and setting it to something like 500,500 is all fine and dandy but how do I change this to use to use my own size in C++ , at runtime? I just cant seem to find the FVector2D anywhere to change it. I know I am missing something obvious :(

Any thoughts?

My code I have been using so far.

 UCanvasPanel* Canvas = Cast<UCanvasPanel>(FoundWidget->GetWidgetFromName(FName(TEXT("Canvas"))));
             UTextBlock* TextArea = Cast<UTextBlock>(FoundWidget->GetWidgetFromName(FName(TEXT("Text"))));
             FVector2D TextSize = TextArea->GetDesiredSize();
 
             if (TextArea != NULL)
             {
                 TextArea->SetText(Text);
             }

           
             //I have tried this but it is not of type class CanvasPanelSlot so it does'nt have the function SetSIze() :(
             // Cast<UCanvasPanelSlot>(Canvas->Slot)->SetSize(TextSize);
             
             TArray<UPanelSlot*> SearchSlots = Canvas->GetSlots();
             for (int32 b = 0; b < SearchSlots.Num(); b++)
             {
                 //Cast and Set the Size of each Slot
                 UCanvasPanelSlot* widgetSlot = Cast<UCanvasPanelSlot>(SearchSlots[b]);
                 if (widgetSlot != NULL)
                 {
                     widgetSlot->SetSize(TextSize);
                 }
             }
 

Product Version: Not Selected
Tags:
more ▼

asked Feb 03 '15 at 07:25 AM in C++ Programming

avatar image

yesNinja
103 9 10 16

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

1 answer: sort voted first

Hi, I think you want to set the widget component size like you did for the preview size (example 500,500).

You can use

 /** Sets the draw size of the quad in the world */
 UFUNCTION(BlueprintCallable, Category=UserInterface)
 void SetDrawSize(FVector2D Size);

Your userwidget does not really have a size so you need to update the size of UWidgetComponent

more ▼

answered Jan 26 '16 at 11:13 AM

avatar image

Plosnita
277 5 8 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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