Hi guys, I have a c++ actor which has UInstancedStaticMeshComponent added with
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = GridFloor) in header file.
I created it in constructor, and updated it in PostEditChangeProperty with 2 for loop by X and Y two integer
So the InstacedStaticMeshComponent will be a grid with xsize * ysize.
When I change the size integer to 1010 it takes almost 1~2 sec, and when i change it like 2020,
the editor freezes like 10sec.
Below is part of my code
.h File
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = GridFloor)
class UInstancedStaticMeshComponent* GridFloor;
.cpp in Constructor
GridFloor = CreateDefaultSubobject<UInstancedStaticMeshComponent>(TEXT("GridFloor"));
GridFloor->AttachTo(Root);
GridFloor->bCastDynamicShadow = false;
GridFloor->CastShadow = false;
GridFloor->SetMobility(EComponentMobility::Static);
.cpp in PostEditChangeProperty
GridFloor->ClearInstances();
for (int x = 0; x < XSize; x++)
{
for (int y = 0; y < YSize; y++)
{
FVector tmpTranslation(x*100.0f, y*100.0f, 0.0f);
GridFloor->AddInstance(FTransform(tmpTranslation));
}
}
I already have made same actor through Blueprint (not derive from c++ actor), and when Update it in Construction Script, it just works fine.
when i update the grid in beginPlay, it just fine but i need it in editor, not in-game
Is this a bug? or Did i wrong somewhere??