Fixed UCarlaLight related crash

This commit is contained in:
Axel 2021-09-08 13:01:55 +02:00 committed by bernat
parent 717295e553
commit 808d00d0b0
3 changed files with 12 additions and 3 deletions

View File

@ -222,7 +222,7 @@ void ACarlaGameModeBase::BeginPlay()
Actor->GetComponents(Lights, false);
for(UCarlaLight* Light : Lights)
{
Light->BeginPlay();
Light->RegisterLight();
}
}
EnableOverlapEvents();

View File

@ -14,20 +14,26 @@ UCarlaLight::UCarlaLight()
}
void UCarlaLight::BeginPlay()
{
Super::BeginPlay();
RegisterLight();
}
void UCarlaLight::RegisterLight()
{
if(bRegistered)
{
return;
}
Super::BeginPlay();
UWorld *World = GetWorld();
if(World)
{
UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
CarlaLightSubsystem->RegisterLight(this);
}
bRegistered = true;
}

View File

@ -45,6 +45,9 @@ public:
void OnComponentDestroyed(bool bDestroyingHierarchy) override;
UFUNCTION(BlueprintCallable, Category = "Carla Light")
void RegisterLight();
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
void UpdateLights();