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.

After failing to run the code above I’ve found another way of getting the GameInstance

UClientGameInstance* gameInstance = static_cast<UClientGameInstance*>(GEngine->GameViewport->GetWorld()->GetGameInstance());