I’m adding instances of staticmesh with foliage tool via c++ which works great.
After that, I’m trying to save the changes that made in the editor but nothing happend, it’s not saved.
What should I do?
TActorIterator<AInstancedFoliageActor> foliageIterator(GEditor->GetEditorWorldContext().World());
AInstancedFoliageActor* foliageActor = *foliageIterator;
FStringAssetReference materialAsset(TEXT("/Game/myModel"));
UObject* MyAsset = materialAsset.TryLoad();
UStaticMesh* staticMesh = (UStaticMesh*)MyAsset;
UInstancedStaticMeshComponent* meshComponent = NewObject<UInstancedStaticMeshComponent>(foliageActor, UInstancedStaticMeshComponent::StaticClass(), NAME_None, RF_Transactional);
meshComponent->AttachTo(foliageActor->GetRootComponent());
meshComponent->SetStaticMesh(staticMesh);
meshComponent->RegisterComponent();
FTransform transform = FTransform();
transform.SetLocation(FVector(100,100,0));
meshComponent->AddInstance(transform);