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"

All UserWidgets In Viewport

i know there is IsInViewport to check if a userwidget is currently in the viewport. but is there a way to list all userwidgets that are currently in the viewport? or do i have to create a list on my own?

Product Version: UE 4.19
more ▼

asked Jun 24 '18 at 04:02 AM in Blueprint Scripting

avatar image

89 2 13 16

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

2 answers: sort voted first


Just save references in a TArray ( if they are instances of the same userWidget )

TArray is the Ue4 array and it is similar to a STL std::array, it has many functionalities like addunique,sort..

Or you can use a map made of a bool(isInViewport)and the reference to your widget

This way you can add ,remove and add again a widget without have to create it again, because it is still referenced and thus not garbage collected. And easily check to see if it is in viewport.

Hope it helps!

more ▼

answered Jun 24 '18 at 07:59 AM

avatar image

1k 17 8 15

avatar image nco2k Jun 24 '18 at 08:30 AM

hi, if i have to manage it on my own, i guess i will simply use a set. but i was hoping to avoid the extra work. :D

avatar image AZTECCO Jun 24 '18 at 11:32 AM

Ok then use getAllWidgetsOfAClass and filter with isInViewport..

avatar image nco2k Jun 25 '18 at 04:06 AM

hi again, i dont need to know the widgets of a class. i need to know the userwidgets that have been added to the viewport (CreateWidget -> AddToViewport). but your answer lead me to GetAllWidgetsWithInterface, which i could use for exactly that. thanks!

avatar image AZTECCO Jun 25 '18 at 06:14 AM

Glad to hear that! :)

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


One method you can use (that will be costly) is (this is done from the perspective of a UUserWidget in my example):

 TArray<UWidget*> AllWidgets;

You'll need to #include "WidgetTree.h", but this will give you an array of all top level widgets. It will not penetrate other UUserWidgets, though. Luckily, WidgetTree is a public member of UUserWidget, so you can recursively iterate through all UUserWidget.

If this doesn't work for you, let me know.

more ▼

answered Jun 25 '18 at 05:15 AM

avatar image

11 1

avatar image nco2k Jun 25 '18 at 05:50 AM

hi and thank you for your reply. im looking for a blueprint solution though. :D for now, im using GetAllWidgetsWithInterface which does exactly what i want.

(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