While Loop in the UMG OnPaint Function causes editor slow downs when switching to the designer tab.

I’m attempting to paint several lines at different angles based on a previous input that can be changed either at runtime or prior. I have a while loop setup to iterate through the angles and stop when it’s reached 360 degrees.

Currently, whenever I have the While Loop connected to the function then compile, switching back to the Designer tab in UMG will cause the editor to drastically slow down and give me this error, infinitely:

The game isn’t running yet, when this shows up. I’m guessing it has something to do with OnPaint maybe being fired before play.

Either way, here’s my blueprint function stripped down:

Any help would be greatly appreciated, thanks!

It might also be good to note that this still happens if I do a check for whether or not any game time has passed:

After looking into some other possibilities, this might have something to do with On Paint being a const function, so I set all loop variables outside of it.

I don’t know if the reasoning is close to being correct, but I got around this issue by setting an integer outside of OnPaint and using a For loop, instead.

Event Graph:

On Paint Function:

Oh my this was so helpful, thank you so much for this, it worked for me too!

(moving the max index value of a for loop outside of OnPaint instead of using other looping structures)

It is still true as an issue in 4.24

:heart:

Rama