Fixed UCarlaLight related crash
This commit is contained in:
parent
717295e553
commit
808d00d0b0
|
@ -222,7 +222,7 @@ void ACarlaGameModeBase::BeginPlay()
|
||||||
Actor->GetComponents(Lights, false);
|
Actor->GetComponents(Lights, false);
|
||||||
for(UCarlaLight* Light : Lights)
|
for(UCarlaLight* Light : Lights)
|
||||||
{
|
{
|
||||||
Light->BeginPlay();
|
Light->RegisterLight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EnableOverlapEvents();
|
EnableOverlapEvents();
|
||||||
|
|
|
@ -14,20 +14,26 @@ UCarlaLight::UCarlaLight()
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCarlaLight::BeginPlay()
|
void UCarlaLight::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
RegisterLight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCarlaLight::RegisterLight()
|
||||||
{
|
{
|
||||||
if(bRegistered)
|
if(bRegistered)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
UWorld *World = GetWorld();
|
UWorld *World = GetWorld();
|
||||||
if(World)
|
if(World)
|
||||||
{
|
{
|
||||||
UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
|
UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
|
||||||
CarlaLightSubsystem->RegisterLight(this);
|
CarlaLightSubsystem->RegisterLight(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bRegistered = true;
|
bRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
|
|
||||||
void OnComponentDestroyed(bool bDestroyingHierarchy) override;
|
void OnComponentDestroyed(bool bDestroyingHierarchy) override;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Carla Light")
|
||||||
|
void RegisterLight();
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
|
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
|
||||||
void UpdateLights();
|
void UpdateLights();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue