Download

Exposing RequestingUnloadAndRemoval via BP Function Library

Hi , I’m a bit new to exposing c++ functionality to Blueprints. Here is the header and script for what im trying to do which should be simple which is setting “RequestingUnloadAndRemoval” to true. Unfortunately they keep returning with the error:
Error (active) E0265 member “ULevelStreaming::bIsRequestingUnloadAndRemoval” (declared at line 157 of “D:\U4.25Real\UnrealEngine\UnrealEngine-4.25\Engine\Source\Runtime\Engine\Classes\Engine\LevelStreaming.h”) is inaccessible

I think this is a scoping error but i’m not sure what I need to set public or protected to get past the accessibility error. Any pointers would be appreciated.

Header File:
#include “CoreMinimal.h”
#include “Kismet/BlueprintFunctionLibrary.h”
#include “Kismet/GameplayStatics.h”
#include “Runtime/Engine/Classes/Engine/LevelStreaming.h”
#include “MyBlueprintFunctionLibrary.generated.h”

/**
 * 
 */
UCLASS()
class OPTIMIZEDGF_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
public:
	GENERATED_BODY()

 
	UFUNCTION(BlueprintCallable, Category = "Some Category")`Preformatted text`
	static bool DestroyStreamingLevelInstance(FString LevelName, AActor* Sender);
	
};

Main C++ file:
#include “MyBlueprintFunctionLibrary.h”

bool UMyBlueprintFunctionLibrary::DestroyStreamingLevelInstance(FString LevelName, AActor* Sender)
{
if (Sender)
{
UWorld* pWorld = Sender->GetWorld();
if (pWorld) {
ULevelStreaming *pStreaming = UGameplayStatics::GetStreamingLevel(pWorld, FName(*LevelName));
if (pStreaming)
{
pStreaming->bShouldBeLoaded = false;
pStreaming->bShouldBeVisible = false;
pStreaming->bIsRequestingUnloadAndRemoval = true;

            return true;
        }
    }
}
return false;

}