Fix for StreetLights not registering in UCarlaLightSubsystem.
This commit is contained in:
parent
5a41195afc
commit
c7ce0eab7a
|
@ -7,6 +7,7 @@
|
|||
#include "Carla.h"
|
||||
#include "Carla/Game/CarlaGameModeBase.h"
|
||||
#include "Carla/Game/CarlaHUD.h"
|
||||
#include "Carla/Lights/CarlaLight.h"
|
||||
#include "Engine/DecalActor.h"
|
||||
#include "Engine/LevelStreaming.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
|
@ -196,6 +197,19 @@ void ACarlaGameModeBase::BeginPlay()
|
|||
if (LMManager) {
|
||||
LMManager->RegisterInitialObjects();
|
||||
}
|
||||
|
||||
// Manually run begin play on lights as it may not run on sublevels
|
||||
TArray<AActor*> FoundActors;
|
||||
UGameplayStatics::GetAllActorsOfClass(World, AActor::StaticClass(), FoundActors);
|
||||
for(AActor* Actor : FoundActors)
|
||||
{
|
||||
TArray<UCarlaLight*> Lights;
|
||||
Actor->GetComponents(Lights, false);
|
||||
for(UCarlaLight* Light : Lights)
|
||||
{
|
||||
Light->BeginPlay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ACarlaGameModeBase::Tick(float DeltaSeconds)
|
||||
|
|
|
@ -15,6 +15,11 @@ UCarlaLight::UCarlaLight()
|
|||
|
||||
void UCarlaLight::BeginPlay()
|
||||
{
|
||||
if(bRegistered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Super::BeginPlay();
|
||||
|
||||
UWorld *World = GetWorld();
|
||||
|
@ -23,6 +28,7 @@ void UCarlaLight::BeginPlay()
|
|||
UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
|
||||
CarlaLightSubsystem->RegisterLight(this);
|
||||
}
|
||||
bRegistered = true;
|
||||
}
|
||||
|
||||
void UCarlaLight::OnComponentDestroyed(bool bDestroyingHierarchy)
|
||||
|
|
|
@ -104,4 +104,6 @@ protected:
|
|||
private:
|
||||
|
||||
void RecordLightChange() const;
|
||||
|
||||
bool bRegistered = false;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue