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?
asked Jun 24 '18 at 04:02 AM in Blueprint Scripting
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!
answered Jun 24 '18 at 07:59 AM
One method you can use (that will be costly) is (this is done from the perspective of a UUserWidget in my example):
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.
answered Jun 25 '18 at 05:15 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here