I am going back to Unreal Engine after a while and discovering the Viewmodel system on UMG.
It looks pretty cool so I am trying to use it for everything.
Right now, I am implementing an storage system so I want to be able to have a list of slots, empty or filled with object.
So I am using a Wrap Box and I want it to bind to my Viewmodel to create children according to an array in my Viewmodel.
But if I compile with just that, I’ve got this issue:
[Compiler] No binding found from an array of viewmodels to StorageContainerEntries_Viewmodel_Extension -> SetItems. Please find StorageContainerEntries_Viewmodel_Extension on the root widget and add this binding or remove the Viewmodel extension on widget StorageContainerEntries from its details panel.
Unfortunately, I don’t understand the message… What I am supposed to do?
Is it the expected workflow or should I use widget binding and setup from “View Bindings”? If this is the case, how can make such a binding?
Thank you for any help you could bring, I could not find anything about Panel Widget children binding (only ListView but this is not the layout I would like to use here).
That compiler line is the workflow, not a broken Wrap Box. The extension on StorageContainerEntries does not bind itself. Set Items has to be bound on the root widget, from an array of viewmodels.
Open View Bindings for the widget blueprint (the panel for the whole widget, not the Wrap Box details). Add a binding:
Source: the array on your container viewmodel.
Destination: StorageContainerEntries, then the viewmodel extension, then Set Items.
The array has to be an array of viewmodel objects (your slot viewmodel class) with Field Notify, not an array of item structs. The extension spawns the entry widget once per element and assigns that element as the entry’s viewmodel. A struct array has no conversion to “array of viewmodels”, which is the same error.
Changing the array only refreshes the Wrap Box if the property notifies. Set it through the viewmodel setter, or Broadcast Field Value Changed. Mutating the array in place with no broadcast leaves the panel stale.
List View is the other widget that does this without the extension. For a Wrap Box, the extension plus that one root binding is the path you already started.