Blueprint Example: Custom Container (With Save Support)
Disclaimer:
This example is not part of UMI out of the box.
It shows how you could build a custom world container in Blueprint that:
- Stores
FItemInstanceentries- Implements a
Saveableinterface- Registers itself with your own
SaveSubsystem
You’ll need to adapt names and structs to match your project’s save system.
1. Create a “Saveable” Blueprint Interface
Create a Blueprint Interface, e.g.BPI_Saveable, with these functions:
-
GetSaveGuid- Return Type:
Guid
- Return Type:
-
GetSaveBucket- Return Type:
Name - Example:
"World_Containers"
- Return Type:
-
BuildSaveRecord- Return Type:
FSaveRecord(your project’s save record struct)
- Return Type:
-
ApplySaveRecord- Input:
FSaveRecord(Record)
- Input:
This mirrors the C++ ISaveable interface, but in Blueprint form.
2. Create a Custom Container Blueprint
Create a new Actor Blueprint, e.g.BP_MyCustomContainer.
Add Components/Variables:
- (Optional) Static Mesh for the container (chest, barrel, etc.)
-
Variable:
ContainerGuid- Type:
Guid - Instance Editable: ✔ or not, your call
- SaveGame: ✔ (if you’re using UE’s SaveGame flags)
- Type:
-
Variable:
StoredItems- Type:
ArrayofFItemInstance - SaveGame: ✔
- Type:
BPI_Saveable to this Blueprint.
3. BeginPlay: Generate GUID and Register with SaveSubsystem
InEvent BeginPlay:
- If
ContainerGuidis invalid → create a new GUID - Register this container with your save subsystem so it participates in saving/loading.
In your docs you can just say:
“On BeginPlay, we ensure the container has a GUID and register it with the save system.”
4. Implement GetSaveGuid (BPI_Saveable)
In the BPI_Saveable function GetSaveGuid:
5. Implement GetSaveBucket
In GetSaveBucket:
6. Implement BuildSaveRecord
This part depends on how your FSaveRecord struct is exposed to Blueprint. Conceptually:
- Create a local
FSaveRecordvariable, e.g.Record. - Set its Type (or similar field) to something like
"MyCustomContainer". - Serialize
StoredItemsinto the Record, using whatever approach your save system uses.
FMemoryWriter and FItemRecord:
- A helper function that converts
StoredItemsto something storable inFSaveRecord - Or a more direct approach like an
Array<FItemRecord>field onFSaveRecord.
“In BuildSaveRecord, serialize StoredItems into the save record using your project’s preferred method (Blueprint Function Library, struct fields, or a custom serializer).”
7. Implement ApplySaveRecord
This is the inverse: clear current items, then rebuild from the save data.
Pseudo-graph:
- A helper node like
BytesToItemArray(Bytes) → StoredItems, or - Direct struct/array fields on
FSaveRecord.
8. Hooking It Up to UMI
Once you’ve gotStoredItems working with your save/load:
-
Use UMI’s container/interaction logic to:
- Open the container UI and show
StoredItems - Allow transferring items between player inventory and
StoredItems - Optionally use UMI helpers for adding/removing items in this container
- Open the container UI and show
StoredItems exactly like a secondary inventory array and reuse your existing UI logic.