I’m building a procedural ammo display system that will automatically increase/decrease the number of displayed bullet images depending on the defined max ammo for the weapon at the present time (i.e. the weapon might have a max of 30 rounds, 45, or any other arbitrary integer) and I’ve built a material that will automatically resize the bullet icon based on the current max ammo value.
What I need to do is create an arbitrary number of Images in UMG which can then be added to an array, and process each one individually (so that its color can be changed depending on whether or not that round has been fired, as well as any alternate attributes about that round such as bonus damage dealt by it, etc.) using a loop.
The problem is, there doesn’t SEEM to be a way to create a reference to an Image asset at runtime. You can generate a Slate Brush and ASSIGN it to an image, but without creating a unique image widget in the Viewport editor UMG doesn’t seem to recognize it. I tried creating an array of Image-type object references, resizing it, and then setting the corresponding values for each of its members and assigning them to render as a part of the master ammo readout widget using Add Child to Canvas (under the assumption that UE4 would simply create arbitrary image object references to fill the array) but it doesn’t work.
It seems like there ought to be a way of doing this WITHOUT just creating like, 99 identical Image widgets, hiding them, and then assigning attributes to and unhiding the appropriate number as-needed, but I can’t actually figure it out.
How does one create Widgets (not user-defined widget blueprints, but CORE widgets like Images, Borders, Buttons, etc) at runtime?