Can't seem to get a texture from an array?

Hi,
So I’m trying to change the image brush in my UI widget dynamically, grabbing the image (Texture 2D) from the struct of a randomly generated unit in my game. The image is supposed to be a character portrait that gets assigned randomly when the unit is generated.
This is what the unit generation function looks like:

http://www.zduhach.se/blog/Images/Unit_generation2.png

It’s built in a function library and the array of portraits is a local variable I manually populated with images. The idea is to grab a random image from the “Portrait” array and set it as the “Character Portrait” variable in the struct.

In my widget I’ve created an image object and a binding to change the appearance. This is what the binding looks like:

http://www.zduhach.se/blog/Images/Widget_binding.png

So basically it loads a default image file as long as no item (in a list of units) is selected, once an item is selected it should load the image from the struct of the selected unit.

http://www.zduhach.se/blog/Images/result04.png

Left is what the widget looks like loading the default image set in the binding, right is the result of selecting an item in the list and getting the image stored in the unit struct. I’ve fiddled around with it and tried to change the image in the widget using different methods but that doesn’t change anything. From what I can tell the problem lies in the unit generation and changing the image variable of the unit struct. Hiding the pin and not changing the image that is set as the default of “Character Portrait” changes the image fine in the widget, but I can’t figure it what I’m doing wrong when setting the variable to a random array element in the struct?

Okay small update, I’ve narrowed the problem down to the Character Portraits array not returning anything on Get.

I hooked up a button that runs my unit generation function with two new outputs, one gets index 0 in the Character Portraits array, and the other gets index 0 in an array of strings. I just hooked both the outputs up to a print string function. The result can be seen on the right, one empty line and the string from index 0

http://www.zduhach.se/blog/Images/arrayGet.png

Is this a bug or are you not allowed to store Texture2D in an array?

Okay, so a work around that works is to change the struct variable to a “slate brush” and set that from an array of slate brushes instead. Only problem here is that I have to set the “max” value of the “random int in range” node manually, hooking up the length of the array will have every nth Get store a void value and the white box from the first post appears again.

Brilliant, thank you so much. I was experiencing this problem in a game jam with only 3 hours left, and this really saved my hide. It was a card game without any cards until I tried your fix.

https://ldjam.com/events/ludum-dare/41/deck-cutters-hearth-of-the-cards

Cheers m8, glad you made it on time!