I change and recompile the ShipAimComponent .h file,
There is a waring:
The UE will crash when I play in editor.
What causes the problem? Hot reload bug or my problem?
/********* In .h File *********/
// The property in ShipAimComponent .h file,
UPROPERTY(Transient, DuplicateTransient)
UCrossHairUserWidget* ShipCrossHairUserWidget = nullptr;
/********* In .cpp File *********/
// Called when the game starts
void UShipAimComponent::BeginPlay()
{
InitShipAimComponent();
Super::BeginPlay();
}
void UShipAimComponent::InitShipAimComponent()
{
// Create Cross Hair UI
const UWorld* World = GetWorld();
if (ShipCrossHairUserWidgetClass && ShipCrossHairUserWidget == nullptr && World && !World->bIsTearingDown)
{
ShipCrossHairUserWidget = CreateWidget<UCrossHairUserWidget>(GetWorld(), ShipCrossHairUserWidgetClass);
ShipCrossHairUserWidget->AddToViewport();
}
}
// Call by Charactor Input ( Move forward )
void UShipAimComponent::MoveCrossHairVertical(const float Val, const APlayerController* PlayerController)
{
// !!!!!!! Crash always happens in here !!!!!!!
UE_LOG(LogTemp,Warning,TEXT("%hs"),(ShipCrossHairUserWidget == nullptr ? "ShipCrossHairUserWidget == nullptr":"ShipCrossHairUserWidget != nullptr"));
if(IsValid(ShipCrossHairUserWidget) && ShipCrossHairUserWidget->IsInViewport())
{
}
}