Problem resizing an array within a struct
I'm building a grid-based inventory system, and can't seem to get this function to work. Basically, I created a 2D array by putting an array within a struct, then making an array of that struct. So we have the array ContainerInventory, which contains elements of the type struct Container Column, which in turn has an array of the inventory slots struct.
Whats happening is, when the container is initialized, I just want to resize ContainerInventory to match the pre-defined container width, then iterate through ContainerInventory and set all the empty arrays within ContainerColumn to match the pre-defined height. However, when it prints out the length of each Items array, it just says 0. Was wondering if someone could explain if I'm doing something wrong or being really dumb?
Quick edit to clarify a couple things, both the width and height are set to a value of 5. It appears to resize the ContainerInventory variable correctly, as it prints 5 of the message Column Size - 0.
you can't directly set an "array inside a struct inside an array" when using blueprint. you can do it in c++ or you can make a temp array of structs that you use to create the outer array.
but if your goal is to make a grid of items, why not put them all in the same array? you could use modulus on the iterator to format a single array of objects into a 2D grid:
that way you can separate content from presentation, allowing you to swap out the formatting style without duplicating the content. you can display the same list of objects as a circle menu, album flip book, scrolling list, skill tree, grid list, horizontal list, tabs, venn diagram, flow chart, etc... just by swapping out this logic.
Follow this question
Once you sign in you will be able to subscribe for any updates here