void AGridManager::CreateTile(int indx)
{
//auto TileName = FString(“Tile_”) + FString::FromInt(indx);
//auto TileObj = CreateDefaultSubobject(FName(*TileName));
auto TileObj = NewObject<UGridTileComponent>(this);
TileObj->SetRelativeLocation(TileLocations[indx]);
TileObj->SetStaticMesh(DefaultMesh);
TileObj->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
UE_LOG(LogTemp, Warning, TEXT("%s adding to Tiles"), *TileObj->GetName())
AddTile(Tiles, TileObj);
}
So This is the code responsible for creating tiles.
If I use comented out part instead of New Object editor just crashes.
This is what I would expect to show all the time
But wehnever I move it around it just disapears, and shows uponly after i change grid scale or adjust location by typing it. Anyideas how to prevent this from happening?
P.S
UGridTileComponent is child of StaticMeshComponent, at this point it’s prety much empty will need it latter for some customizations.
Also create tile is part of this, which is called from BP on construction
void AGridManager::GenerateTiles()
{
GenerateTileLocations();
int TileCount = ScaleX * ScaleY;
for (int i = 0; i < TileCount; i++) {
CreateTile(i);
}
}