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: 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:
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. 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, 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.
answered Dec 07 '15 at 09:53 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here