GetInstanceCount() returns 1 after removing an instance

The_untextured
Sat, 02 Mar 2024 21:40:08 +0000
C++

I am having a majour problem.

I have a Hierarchical Instanced Static Mesh Component which can be modified during runtime and can be saved/loaded. When I remove an instance, if I save the game soon after, only the instance which I just removed gets saved. (All the rest get discarded) I checked and it is not a problem in my code. GetInstanceCount() returns 1 for some reason.

I tried looking at the UE source code but I can’t seem to find the problem.

Here is my save code:

for (int32 in = 0; in < i->GetInstanceCount(); in++) {
    FInstanceData d;
    i->GetInstanceTransform(in, d.Transform, true);
    d.Variation = i->Variation;
    OutData[id] = d;
    id++;
}

Where i is of kind class UHISM : public UHierarchicalInstancedStaticMeshComponent object pointer (A custom class)

Anybody has any idea as to why this happens?

1 post - 1 participant