Array isnt updating, for each loop only running once.

Hey there,

Im having an issue with for each loops.

You can see here some pretty simple nodes.

heres whats in the array.

Ok Easy. So this should show 5 prints with each number.

h

Ah…So it went through…once? Ok so what happens if I change the list.

Lets test.

Right so it didnt even update it to the new array I manually changed?

Anyone have any idea whats going on?

Thanks for reading.

So, your blueprint is wrong. Take a look at my result. I’m guessing you want to achieve something similar to this, right?

Your setup logic should be like this:
Your parent class widget should inherit a vertical or horizontal box, and then you can add the child class, as in the screenshot below.

Even if you implement the scroll box, it should be like this:

To put it simple, I’m guessing your widget component is the problem. This is the parent widget class component hierarchy. Hope it helps.

I think Im confused. Ive used this way several other times and it works normally but this time its acting up.

lets say I swap out the scrollbox entirely. Just adding to a vertical box.


This is the hierarchy.
Inside it is this

and this is the default values

So it should should produce 5 widgets, with the list names.


But it produces this.

So it Could be the title card widget itself. which just contains this

Now this hierachy is just this
image

Essentially pulling from a global button I made So I could adjust it and every button would change here.

v

This system has worked everywhere else. But for some reason right now in this specific blueprint. It just doesnt want to work. It clogs itself up.

Ok Easy. So this should show 5 prints with each number.

Print the Length of this array:

What do you get? if you get nonsense, select the For Each Loop node and hit F9 to add a breakpont. Run the project, do you hit the breakpoint?

1 Like

It’s made inside the widget, It’s nothing special. Just inside the widget, created the variable, made it an array and filled it.

It doesn’t get pulled from anywhere else. It’s just a manually made variable in the widget.

In fact wierdly, what If I just totally removed everything except the print

Still shows this xD.

When the details is this

Something funnys going on.

This widget is part of a broader widget which uses a widget switcher but Ive used this same system before and its always been fine.

My bet is that you’re looking at the wrong widget. Check my post above.

Ive used this same system before and its always been fine.

Precisely, this works - we’re looking for an issue that is elsewhere.

1 Like

Ah sorry didnt see that, the length is counting something

This is the results of this noodle maze.

Which is defo strange now. 0 to 4 overall 5. the list is wrong and gets lost after number 1.

Wierder still the details list looks like this lol.

I did a breakpoint on the for each loop, Something to note, I opened this up yestarday and the “length” node was errored, I refreshed it (Just right click refresh) The error went away and Ive had issues since.

Breakpoint hit.

and inside the loop

Breakpoint hit.

Apparently we are looking at the correct widget, my bad.

It’s printing empty array entries:


Is this :point_up: an Instance Editable variable that you Expose on Spawn?

1 Like

At the moment, like my other ones It’s neither instance editable nor exposed on spawn. If I turn them both on. I get the same result.

image

Missing list information, but the gap does exist.

Ok Not sure if this matters at all but I have a widget switcher created when the options are made and the same thing happens. This whole system might be problematic

I attached this to my main hub

Same problem except it looks like this

image

wierd huh

I was merely hoping we were piping in data dynamically and the array was overwritten.

Ok Not sure if this matters at all but I have a widget switcher created when the options are made and the same thing happens. This whole system might be problematic

That was my next thought - what if you manually create just this widget as a stand alone on Begin Play, without the switcher? Does it behave normally?

Essentially, the array has 5 entries but they never get updated. That’s the gist, right?

1 Like

Also, which switcher index is this widget at? And what is the default switcher index? I have a weird feeling it has something to do with initialisation.


Try this:

  • remove the widget from the switcher
  • modify the array, save, compile
  • add it back to the switcher

Thinking about it, I’ve seen widgets retain stale data.

1 Like

And here’s another thing to try:

  • in the widget, set the array as Instance Editable:

  • in the Switcher owner, select the widget with the abovementioned array and populate it there:

1 Like

Yeah, this is not a dynamic system, it never changes. It doesn’t need to pull from anything. So it just has to add the text to the box and put it in the vert box. (Ill then be attaching some non-dynamic but animated stuff around it.)

Ok so I removed it from the switcher, changed the data, reput it into the switcher and then tried again and lo and behold.

image

Counting correctly

Shows up correctly.

What black magic is this xD.

are switchers just to be avoided? why would a switcher hold onto stale data?

So it seems it no longer gets its infomation from the widget, but from the switcher widget overridding the initial widget.

It can get nasty like that and a nuisance to update. Try the thing from the post above:

in the widget, set the array as Instance Editable:

it should work fine. :crossed_fingers:

1 Like

My brain is foggy today, Yeah, that above is exactly it. It no longer uses the updates from the initial widget, as soon as it’s under the widget switcher widget it sources all its content from there now I guess.

Absolutely wild. This actually might have cleared up some problems I was having like 6 months ago as well that I solved but didn’t really understand what or how when I used another switcher for the main game.

Iv now zerod out my options widget list.

And now making the adjustments from the “master hub” widget switcher with the list widget inside it.

Thank you for helping me plough through this, I’ve been 2 days deep and absolutely baffled. Interesting system that I’m defo going to take advantage of.

1 Like