Calling SetPositionInViewport with coordinates outside the viewport on tick breaks tick.
Calling SetPositionInViewport appears to accept only coordinates relative to the viewport (FVector2D(100.f,100.f) shows top left with an offset), but when converting absolute to local coordinates using the viewport geometry we end up with wrong coordinates
Whatever is going on there is a pain to debug since a wrong coordinate appears to break the engine in half. I also read reports that SetPositionInViewport did not work at all in UE5.1. Well… Great
Yes, there is something weird happening with it. I made a widget appear in a specific place in the viewport, and it works on my machine, but the same code on my coworker’s computer always places the widget in the top left corner, and I have no idea why.
Currently I am using a canvas slot again to make it work, it is awkward.
CanvasSlot->SetPosition(LocalPosition);
You must be very careful with SetPositionInViewport and (I think) canvas slots as well to clamp coordinates within the available geometry. If you do this wrong during tick, tick just stops.
Yes, I experienced it as well. I had to fall back to adding widgets to a canvas panel instead of to the screen even though scaling can mess up the visuals a bit, but at least the positioning works.
And you’re right about the ticks too. When not rendered, the widget stops ticking, either because it’s off-screen or its visibility is Hidden or Collapsed. Sometimes you have to use the tick function of the external widget to trigger the functionality of the hidden one.
That’s odd when you think about it. Tick is about the least I’d worry about if it runs without any heavy custom code attached to it. Odd, because I have not been able to detect an accurate “on screen” situation any way with widgets… Either by visibility or for example clipped in a scroll box: