# What is the best way to save Hierarchical Instanced Static Mesh Component?

**URL:** <https://forums.unrealengine.com/t/what-is-the-best-way-to-save-hierarchical-instanced-static-mesh-component/483028>\
**Category:** Asset Creation\
**Tags:** Hierarchical-Instanced-Static-Mesh, serialization, Instanced-Mesh, unreal-engine, question\
**Created:** [May 7, 2021, 10:33am UTC](https://forums.unrealengine.com/t/what-is-the-best-way-to-save-hierarchical-instanced-static-mesh-component/483028 "2021-05-07T10:33:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Digital\_Dreamer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Digital\_Dreamer](https://forums.unrealengine.com/u/Digital_Dreamer)\
**Post date:** [May 7, 2021, 10:33am UTC](https://forums.unrealengine.com/t/what-is-the-best-way-to-save-hierarchical-instanced-static-mesh-component/483028/1 "2021-05-07T10:33:51Z")

</div>

Currently I just serialize and write a `TArray` with the `FTransform` of each instance to a .save file, which I can load in and feed to my mesh component by using `AddInstances(...) `.

Does anyone else know a better/faster way to save&load Hierarchical Instanced Static Mesh Component?

Thanks,

---

<div class="post-metadata">

**Author:** ![Digital\_Dreamer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Digital\_Dreamer](https://forums.unrealengine.com/u/Digital_Dreamer)\
**Post date:** [May 7, 2021, 10:36am UTC](https://forums.unrealengine.com/t/what-is-the-best-way-to-save-hierarchical-instanced-static-mesh-component/483028/2 "2021-05-07T10:36:08Z")

</div>

Also this is my current save&load code:

```
void ASpawnerParent::SaveInstances()
{
	MakeSaveDirectory();

	FBufferArchive ToFile;

	ToFile << InstanceTransforms;
	
	const FString& FullFilePath = SaveDirString + "/" + "PlantSpawner" +".save";
	
	if(!FFileHelper::SaveArrayToFile(ToFile, * FullFilePath))
	{
		UE_LOG(LogTemp, Warning, TEXT("Failed to Save") );
		return;
	}
	UE_LOG(LogTemp, Log, TEXT("Save Succesful") );

}

void ASpawnerParent::LoadInstances()
{
	TArray<uint8> TheBinaryArray;
		
	const FString& FullFilePath = SaveDirString + "/" + "PlantSpawner" +".save";
	if(!FFileHelper::LoadFileToArray(TheBinaryArray, *FullFilePath))
	{
		UE_LOG(LogTemp, Warning, TEXT("Failed to Load") );
		return;
	}
	FMemoryReader FromBinary = FMemoryReader(TheBinaryArray, true); 
	FromBinary.Seek(0);

	FromBinary << InstanceTransforms;
	
	UE_LOG(LogTemp, Log, TEXT("Load Succesful") );
}
```

---

<div class="post-metadata">

**Author:** ![Kedriik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kedriik](https://forums.unrealengine.com/u/Kedriik)\
**Post date:** [September 2, 2023, 10:47am UTC](https://forums.unrealengine.com/t/what-is-the-best-way-to-save-hierarchical-instanced-static-mesh-component/483028/3 "2023-09-02T10:47:38Z")

</div>

In my opinion better way is to use Instanced Foliage Actor.  
Iterate through all of your Hierarchical Instanced Static Mesh Components, for each create Instanced Foliage Actor, set static mesh, then loop from instances count and add each transform.
