I am currently in need of a recursive structure (or rather, an alternative to a recursive structure since UE doesn't let you create one). I am trying to create a setup that can be used for dynamic menus. Essentially, this structure will drive the appearance and behavior of a button. My problem is, the button needs to be able to contain data for additional buttons. And those additional buttons need to be able to contain data for additional buttons, etc.
One option is to simply create all the buttons at the beginning and pass in the child buttons by reference to the parent button. But this seems very messy. It also doesn’t work too well when the child buttons need to be dynamically generated (for example, if a button needs to be created for each player in the game).
Structs are out because a struct can’t contain a data type equal to itself. This makes sense if it’s not an array because compiling this struct would cause infinite recursion. However, if you have an array of that struct with 0 elements, it should work since there’s no recursion there. But it doesn’t let you.
So is there a workaround for this?
One option is to simply create all the buttons at the beginning and pass in the child buttons by reference to the parent button. But this seems very messy. It also doesn’t work too well when the child buttons need to be dynamically generated (for example, if a button needs to be created for each player in the game).
Structs are out because a struct can’t contain a data type equal to itself. This makes sense if it’s not an array because compiling this struct would cause infinite recursion. However, if you have an array of that struct with 0 elements, it should work since there’s no recursion there. But it doesn’t let you.
So is there a workaround for this?
Comment