Last active
July 5, 2023 09:31
-
-
Save ivo-alves/07a29a255600fc55ef2413ee7b20039a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// non static | |
FDelegateHandle handle = FWorldDelegates::OnCurrentLevelChanged.AddUObject(this, &Foo::OnLevelLoaded); | |
// static | |
FWorldDelegates::FWorldInitializationEvent::FDelegate Foo::OnPostWorldInitHandle = nullptr; | |
Foo::Bar() | |
{ | |
if (!OnPostWorldInitHandle.IsBound()) | |
{ | |
OnPostWorldInitHandle = FWorldDelegates::FWorldInitializationEvent::FDelegate::CreateStatic(&Foo::OnWorldInit); | |
FWorldDelegates::OnPostWorldInitialization.Add(OnPostWorldInitHandle); | |
} | |
} | |
void Foo::OnWorldInit(UWorld* World, const UWorld::InitializationValues IVS) | |
{ | |
GEngine->AddOnScreenDebugMessage(-1, 5.5f, FColor::Blue, TEXT("OnWorldInit!")); | |
FLatentActionInfo Info; | |
UGameplayStatics::LoadStreamLevelBySoftObjectPtr(World, LoadingDrill->DrillSublevel, true, false, Info); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// non-static | |
UFUNCTION() | |
void OnLevelLoaded(ULevel* NewLevel, ULevel* OldLevel, UWorld* World); | |
// static | |
static void OnWorldInit(UWorld* World, const UWorld::InitializationValues IVS); | |
static FWorldDelegates::FWorldInitializationEvent::FDelegate OnPostWorldInitHandle; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment