Appearance
Saving and restoring inventories
Choose the scope
Each built-in container implements GetSaveData() and LoadFromSaveData() for its own contents, including containers nested inside items. A manager combines its root containers and manager stat tags into one snapshot. Quick slots have their own snapshot of slot count and item-ID assignments. The inventory subsystem combines all registered managers in the current world with quick slots found on their owning actors.
Manager, quick-slot, and subsystem save/load functions are Blueprint-callable. Individual container methods are currently C++ only; FRicContainerSaveData is marked NotBlueprintType. See the Blueprint save and load guide for choosing an entry point.
Save-data model
Include Persistence/RicSaveTypes.h.
FRicSlotSaveData: slot index, item definition, item GUID, tag counts, and nested containers.FRicContainerSaveData: container definition, GUID, and slot records.FRicContainerManagerSaveData: managerFNameID and root containers.FRicQuickSlotsSaveData: shortcut count and index-to-item-GUID assignments.FRicActorSaveData: manager and quick-slot data for an owner.FRicSaveData: registered owners' data.
Grid records preserve occupied cells. The same item GUID may occur in several slot records for a multi-cell item; load reconstructs one item and places its reference in those cells.
Native recursive serialization
Slot and container structures implement Serialize(FArchive&), custom struct traits, equality checks, and recursive GC reference collection. The serializer explicitly handles native fields such as indices, tag maps, GUIDs, and nested arrays.
A reflected save-game property containing FRicSaveData uses these native serializers. There is no need to flatten the inventory merely because the nested structures contain non-UPROPERTY members.
The structures also register an inventory custom serialization version. That version controls reading the inventory representation; your game should still manage its own save format and migration policy.
Create a SaveGame class
Replace YOURGAME_API with your game module macro.
cpp
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/SaveGame.h"
#include "Persistence/RicSaveTypes.h"
#include "InventorySaveGame.generated.h"
UCLASS()
class YOURGAME_API UInventorySaveGame : public USaveGame
{
GENERATED_BODY()
public:
UPROPERTY(SaveGame)
FRicSaveData InventoryData;
UPROPERTY(SaveGame)
int32 GameSaveVersion = 1;
};Keeping the snapshot in a reflected property also lets GC track definition references recursively while the save object is alive.
Capture and write
Call this from authoritative gameplay code after inventory owners have registered:
cpp
#include "InventorySaveGame.h"
#include "Subsystems/RicInventorySubsystem.h"
#include "Kismet/GameplayStatics.h"
bool SaveInventories(UObject* WorldContext)
{
URicInventorySubsystem* Inventory =
URicInventorySubsystem::GetInstance(WorldContext);
if (!Inventory)
{
return false;
}
UInventorySaveGame* Save = Cast<UInventorySaveGame>(
UGameplayStatics::CreateSaveGameObject(
UInventorySaveGame::StaticClass()));
if (!Save)
{
return false;
}
Save->InventoryData = Inventory->GetSaveData();
return UGameplayStatics::SaveGameToSlot(
Save, TEXT("Inventory"), 0);
}For one inventory, use Manager->GetSaveData(). Store quick-slot data separately if you bypass world-level capture.
Disk writing is supplied by Unreal's save-game APIs or your chosen storage layer. The inventory subsystem itself captures and restores inventory; it does not choose slots or automatically save on exit.
Restore after owners exist
cpp
#include "InventorySaveGame.h"
#include "Subsystems/RicInventorySubsystem.h"
#include "Kismet/GameplayStatics.h"
bool RestoreInventories(UObject* WorldContext)
{
URicInventorySubsystem* Inventory =
URicInventorySubsystem::GetInstance(WorldContext);
UInventorySaveGame* Save = Cast<UInventorySaveGame>(
UGameplayStatics::LoadGameFromSlot(TEXT("Inventory"), 0));
if (!Inventory || !Save)
{
return false;
}
Inventory->LoadFromSaveData(Save->InventoryData);
return true;
}Run on authority after the intended actors and managers exist. The returned boolean here indicates that a save object was found and restoration was invoked; the plugin load method does not return a complete validation report.
World restore matches registered managers by saved ID. It does not spawn missing actors. Assign stable, unique IDs before restoration; component-generated fallback names are unsuitable for arbitrary persistence across respawns or recreated actors.
Manager restore replaces roots and reconstructs nested state. Restore inventory contents before shortcut assignments. Resolve items again by GUID and refresh UI subscriptions after loading.
Assets and packaged games
Definition assets must still exist and be available to the archive in the packaged game. Keep inventory definitions included in your project's cooking/content rules. Renaming, deleting, or changing definitions can require game-specific save migration.
If you write a custom backend schema, preserve manager IDs, definition references, item/container GUIDs, slot indices, tag counts, nested hierarchy, and shortcut mappings.
Practical verification
Test a round trip containing a rotated multi-cell item, a partially filled stack, nested containers, custom statistics, and quick slots. Compare identity, quantity, placement, and assignment after restarting the game, including a packaged build when that is your target.
Older incomplete saves cannot recover values that were never written. Handle missing assets and game-version changes through your save migration policy.