Download

How can I get GameInstance in BP Library?

// .h
UFUNCTION(BlueprintCallable, Category=“ResLib”)
static void TestFunc();

//.cpp
void UResBPLib::TestFunc() // <—NOTE: no any param
{
//How can I get GameInstance??
}

thx


 if (GEngine->GetWorld() != nullptr && GEngine->GetWorld()->GetGameInstance() != nullptr)
     {
         gameInstance = Cast<UClientGameInstance>(GEngine->GetWorld()->GetGameInstance());
     }  


Quick google.