Changing an image in UI

Hi All,

I can’t figure out how to change an image in the UI (without binding). I was thinking it should be simple. I’ve tried all kinds of recommendations online, but nothing seems to work.

I’m simply taking a texture2d (“Item Image”) from a struct (“Inventory”) and want to update an image (“Equipped Image”) in my UI with that new texture2d. So, basically, I have an image in the UI and I simply want to change it with another image. I’ve tried all kinds of things, Set Brush, Make Brush etc. but nothing works. I don’t get errors, the code executes fine, but the image just doesn’t update.

I’ve seen some references to bugs in UE 4.26 around images but I’ve not found a workaround. I’ve also tried migrating to UE5.0 EA but I get the same result.

Please can someone help me out here? Am I doing something silly in my code?

Many thanks!

HK

Hi,

As a test, are you able to update the image in the following way:

Essentially, on construct with a short delay to manually add a new texture image. Does this work for you? In the above example, it works for me using 4.26.2.

350390-ezgif-1-47d7f6d6ce0d.gif

If you are able to successfully do this, then we need to debug what is being returned from this Item Image parameter, and we need to verify if your custom event, Event Pressed Equip Item, is being called.

1 Like

Thanks so much for the thoughtful response!

Yes, this works fine in event construct with or without the 2 second delay.

So, I put a print string at the end and plugged in the new texture name it should be pulling from the inventory and it correctly prints the new texture on the screen when calling “Event Pressed Equip Item”. So, the event is correctly firing and seems to be pulling out the correct texture from the inventory, but for some reason it’s not updating the image on the screen.

I’m pretty new to blueprints. Am I missing something?

Thanks again!

1 Like

I found out the issue. I’m using Advanced Locomotion System v4 and it uses the same character class for AI and player, so they were all trying to update the widget. I put a check at the start of the code to identify just the player and now things seem to be working! Thanks again for the help!

I am glad you were able to figure it out :slight_smile: