following happens when dragging an empty blueprint (from content panel) that inherits from our class into scene in editor.
Here is Log followed by cpp functions (number is pointer to class).
LogTemp:Warning: CNSTR 000000001BEDF900
LogTemp:Warning: CNSTR 000000001BEA9D00
LogTemp:Warning: CNSTR 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: GEN GRID 0000000023F69600
LogTemp: Setting tile 0 position to X=-450.000 Y=-259.800 Z=0.000
LogTemp: Setting tile 0 position to X=-450.000 Y=259.800 Z=0.000
LogTemp: Setting tile 0 position to X=0.000 Y=-519.600 Z=0.000
LogTemp: Setting tile 0 position to X=0.000 Y=0.000 Z=0.000
LogTemp: Setting tile 0 position to X=0.000 Y=519.600 Z=0.000
LogTemp: Setting tile 0 position to X=450.000 Y=-259.800 Z=0.000
LogTemp: Setting tile 0 position to X=450.000 Y=259.800 Z=0.000
LogTemp: Setting tile 1 position to X=-450.000 Y=-259.800 Z=0.000
LogTemp: Setting tile 1 position to X=450.000 Y=-259.800 Z=0.000
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogSourceControl: Attempting 'p4 fstat -Or H:/UnrealBotBattle/BotBattle/Content/Maps/JoeTest.umap'
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: OnConstruction 0000000023F69600
LogTemp:Warning: CNSTR 000000001BEDCF00
LogTemp:Warning: OnConstruction 000000001BEDCF00
LogTemp:Warning: GEN GRID 000000001BEDCF00
LogTemp: Setting tile 0 position to X=-450.000 Y=-259.800 Z=0.000
LogTemp: Setting tile 0 position to X=-450.000 Y=259.800 Z=0.000
LogTemp: Setting tile 0 position to X=0.000 Y=-519.600 Z=0.000
LogTemp: Setting tile 0 position to X=0.000 Y=0.000 Z=0.000
LogTemp: Setting tile 0 position to X=0.000 Y=519.600 Z=0.000
LogTemp: Setting tile 0 position to X=450.000 Y=-259.800 Z=0.000
LogTemp: Setting tile 0 position to X=450.000 Y=259.800 Z=0.000
LogTemp: Setting tile 1 position to X=450.000 Y=-259.800 Z=0.000
LogTemp: Setting tile 1 position to X=450.000 Y=259.800 Z=0.000
LogTemp:Warning: OnConstruction 000000001BEDCF00
LogTemp:Warning: OnConstruction 000000001BEDCF00
LogTemp:Warning: OnConstruction 000000001BEDCF00
AHexGrid::AHexGrid(const class FObjectInitializer& PCIP)
: Super(PCIP)
{
//gridShape = EGridShape::Hexagon;
//maxQ = 1;
scene = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneComp"));
if (scene)
{
RootComponent = scene;
scene->SetMobility(EComponentMobility::Static);
}
if (!AddInstancedStaticMeshComponent(EHexType::Floor, TEXT("StaticMesh'/Game/Meshes/hextile.HexTile'"),
TEXT("InstancedFloorTile"), TEXT("Material'/Game/Materials/M_Basic_Floor.M_Basic_Floor'"), PCIP))
{
ERROR("BotBattle HexGrid: Failed to Load and Create FloorTile Component...");
}
if (!AddInstancedStaticMeshComponent(EHexType::Wall, TEXT("StaticMesh'/Game/Meshes/hex_wall.hex_wall'"),
TEXT("InstancedWallTile"), TEXT("Material'/Game/Materials/M_Basic_Wall.M_Basic_Wall'"), PCIP))
{
ERROR("BotBattle HexGrid: Failed to Load and Create WallTile Component...");
}
if (!AddInstancedStaticMeshComponent(EHexType::Start, TEXT("StaticMesh'/Game/Meshes/hextile.HexTile'"),
TEXT("InstancedStartTile"), TEXT("Material'/Game/Materials/StartTileMat.StartTileMat'"), PCIP))
{
ERROR("BotBattle HexGrid: Failed to Load and Create StartTile Component...");
}
if (!AddInstancedStaticMeshComponent(EHexType::Flag, TEXT("StaticMesh'/Game/Meshes/hextile.HexTile'"),
TEXT("InstancedFlagTile"), TEXT("Material'/Game/Materials/M_Tech_Hex_Tile_Pulse.M_Tech_Hex_Tile_Pulse'"), PCIP))
{
ERROR("BotBattle HexGrid: Failed to Load and Create FlatTile Component...");
}
WARNING("CNSTR %p", this);
}
void AHexGrid::GenerateGrid()
{
//need to protect against regenerating grid when we do not want to
if (!bGridGenerated)
{
WARNING("GEN GRID %p", this);
this->PositionTiles();
bGridGenerated = true;
}
}
void AHexGrid::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
WARNING("OnConstruction %p", this);
SetActorLocation(FVector(0.0, 0.0, 0.0));
//Reset();
GenerateGrid();
}
Why on earth is OnConstruction called so many times on same object?
Not shown here, but PostInitializeComponents is never called. Why?
Why are multiple objects Constructed and added to scene?
I have included a dropbox link to our code.