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"

For each loop widget

I am working through a project and in the level blueprint after the get all widgets of class node there is a foreachloop node. Why has a foreachloop node been added in this particular case? alt text

Product Version: UE 4.18
foreachloop.png (60.6 kB)
more ▼

asked Apr 22 '18 at 01:10 PM in Blueprint Scripting

avatar image

11 2 4 8

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

2 answers: sort voted first

It gets all widgets (the things you used like buttons,layers,textfields all sorts of thing) from this particular widget class and returns an array(see in your widget editor on the left where all your widgets are-sort of an array list. For every object it gets it set the variable main widget. Following the node i see that something is done wirh the widgets For Every Loop.

more ▼

answered Apr 22 '18 at 01:24 PM

avatar image

207 7 16 15

avatar image Jamesdaley121 Apr 22 '18 at 01:51 PM

Thanks for your response. I am looking to create another mainwidget class so hopefully this setup won't interfere with that.

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

It's sort of a sloppy / lazy way of doing things. It should be safe to just Get element 0 from the array since it's the MainWidget and only 1 instance should ever exist...

Ideally you'd have a proper widget reference stored in one of the globally accessible classes like Game Mode or Game Instance and cast to obtain it. Or even better, use a dedicated widget manager object that keeps tracks of what's valid and not - this is invaluable as the project grows in size.

In case more than 1 instance of MainMenu ever gets created that loop becomes a potential game breaker as you can no longer be certain which MainMenu widget is assigned to that variable.

If you're 100% sure you create the widget once only, it should be safe to use the code as is. Still, feels sloppy.

more ▼

answered Apr 22 '18 at 01:27 PM

avatar image

13.8k 74 25 58

(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