How to add Blueprint classes to an array when they aren't in the level?

I’ve got an inventory-based project where the player has a library (inventory) of furniture assets that can be placed into the world. I followed the UMG tutorials to get me started on adding objects to the inventory and having their assigned image appear in custom buttons in the UI, and I put that function in the Begin Play event of the template object to test it out. It works great, but Begin Play works when the assets are placed in the level at the start of the game. I’m totally new to Arrays and Structs and don’t know where else to put this function about making the inventory. Here is the event inside the Template blueprint that each individual item is based on.

So I need to have some other blueprint (MyPlayerController?) get this furniture item and then add each of its children to the Library struct. It sounds pretty easy, but I’ve never done something like this with objects that don’t exist yet.

If you mean just simply adding class to an array you can do it with the details panel. Just make sure the variable you created is an array, compile and then you can add items with the + sign

Hey, thanks! That’s pretty handy. This totally works for right now at this stage and I will happily use this, but this inventory may reach hundreds of objects at some point in the future. I would really like to have some code that just runs a ForEachLoop for each blueprint instead of hand assigning everything. But at least now I can move forward with testing. Thanks!

If you’re ok with doing a little C++ then you can load up a blueprint array with stuff from a path when the editor starts up.

Thank you. Another good thing to keep in mind. However, I am trying to keep this a Blueprints-only game at the moment so I can deploy to iOS from my Windows PC. Is there no way to access a path inside Blueprints?

Unfortunately not. But I do plan in the coming weeks to put together a free plugin that will take a Content path and a BP array and load the array with stuff from the path. But I’m not 100% sure this is possible without the end user having to install some code callbacks so I can’t guarantee it’ll be useful for you. But if I can manage it I will let you know :slight_smile: