Load Images on Widget

Hi all,
In the Pre Construct event I’m running a couple of function to get a couple of images to display them on a widget. The thing is I think the binding function on these images runs before my functions on the Pre Construct event, so they only get displayed the 2nd time I load them (does that make sense?). Is there a better way to load them on the 1st load?

Perhaps this is the time to abandon function binding and switch to an Event Driven approach. Update the image once - only when needed - rather than 120 times per second for the rest of the game.

Do you think it could work in this instance?

How would you update the images without binding? I can maybe bind an image variable to the image in the widget and update it in an event. Is that what you meant?

It’s just this, call it to update the native image widget:

image

You do not even need a variable. If you do need a variable, because you’re creating widgets dynamically:

And then when widgets are created:

You get a pin to pipe in desired data.


And, finally, nothing stops you from doing both:

Pre-Construct will allow you to preview stuff in Designer and it will use exposed data. And the Custom Event lets you override it run-time.


Polling a variable like this is not that bad:

image

But it does happen as often as Tick allows it. If you need to update the image every frame because the image is changing every frame, this is OK! But if you need to update the image every now and then, those would be wasted cycles; and a little nightmare to debug - as you’ve observed in your original post.

From the performance point of view, this is probably irrelevant / negligible for a single image, but if you have an inventory with hundreds of items, it all adds up.

This is very interesting. I’ll give it a try once I’m back to it. Thanks.