# How can I save/load TArray data?

**URL:** <https://forums.unrealengine.com/t/how-can-i-save-load-tarray-data/472854>\
**Category:** Editor Scripting\
**Tags:** savegame, tarray:-arrays-in-un, unreal-engine, question\
**Created:** [October 13, 2020, 12:31pm UTC](https://forums.unrealengine.com/t/how-can-i-save-load-tarray-data/472854 "2020-10-13T12:31:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_ec3b63dd0812b74e192978029f7aa778](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_ec3b63dd0812b74e192978029f7aa778](https://forums.unrealengine.com/u/Anonymous_ec3b63dd0812b74e192978029f7aa778)\
**Post date:** [October 13, 2020, 12:31pm UTC](https://forums.unrealengine.com/t/how-can-i-save-load-tarray-data/472854/1 "2020-10-13T12:31:14Z")

</div>

## Question

Hello I’m trying to make save/load system in my game. I wrote InventoryComponent that has TArray like this.

```
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class GAME_API UInventoryComponent : public UActorComponent
{
    GENERATED_BODY()
    // skip unnecessary code
    // ...
private:
    TArray<FItemSlot> InventoryArray;
};

```

and initialize 5 default element in BeginPlay() or load SaveGame data. and when I save game, I copy InventoryComponent::InventoryArray to SaveGame::SavedInventoryArray.

```
UInventoryComponent::BeginPlay()
{
	// load save game to CurrentSaveGame (skip code)
	if (CurrentSaveGame)
	{
		InventoryArray = CurrentSaveGame->SavedInventoryArray;
	}
	else
	{
		InventoryArray.Init(FItemSlot(), 5);
	}
}

void UInventoryComponent::SaveCurrent(UMySaveGame* CurrentSaveGame)
{
	CurrentSaveGame->SavedInventoryArray = InventoryArray;
}	

```

All is work clear at first time. but when I load save game from a slot, the engine gives me this warning.

```
LogUObjectGlobals: Warning: Failed to find object 'Object None.None'

```

Can I just ignore this? or did I miss something? please give me some advice.  
one more curious thing is, I think TArray::operation= generate new memory. so in my code there are physically seperated 2 inventory array. but I want have only 1 inventory array. I tried TArray\* SavedInventoryArray but it doesn’t compiled. and TArrayView isn’t solution for me. How can I syncronize InventoryComponent::InventoryArray with SaveGame::SavedInventoryArray? Should I copy whole array like that? I think it’s very waste of memory.

## additional code

ItemSlot is just simple struct that has pointer and count value.

```
USTRUCT(BlueprintType)
struct GAME_API FItemSlot
{
	GENERATED_USTRUCT_BODY()

public:
	// all of variable is UPROPERTY
	UItem* SlottedItem;
	int Count;
};

```

Item is UPrimaryAssetData.

```
UCLASS()
class GAME_API UItem : public UPrimaryDataAsset
{
	GENERATED_BODY()

	// has FText for display name, FSlateBrush for icon.
};

```

and I wrote SaveGame class like this

```
UCLASS()
class GAME_API UMySaveGame : public USaveGame
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		TArray<FItemSlot> SavedInventoryArray;
};

```

## summary

1. why the enigne gives me LogUObjectGlobals: Warning: Failed to find object ‘Object None.None’ warning? How can I fix this?

2. How to send just reference of TArray to another TArray variable? no copy but just reference.
