-
-
Save MauritsDijkman/e9f356e6a1b83d1c3e4606b1ca7e899b to your computer and use it in GitHub Desktop.
This file contains 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
// Fill out your copyright notice in the Description page of Project Settings. | |
#pragma once | |
#include "CoreMinimal.h" | |
#include "Components/SceneComponent.h" | |
#include "AsyncLevelLoadSceneComponent.generated.h" | |
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnLevelLoadedDelegate_ASync); | |
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnLevelLoadedDelegate_Streaming); | |
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) | |
class VREXPPLUGINEXAMPLE_API UAsyncLevelLoadSceneComponent : public USceneComponent | |
{ | |
GENERATED_BODY() | |
public: | |
// Async | |
UPROPERTY(BlueprintAssignable, Category = "AsyncLevelLoad") | |
FOnLevelLoadedDelegate_ASync OnLevelLoadedDelegate_Async; | |
UFUNCTION(BlueprintCallable, Category = "AsyncLevelLoad") | |
void AsyncLevelLoad(const FString& LevelDir, const FString& LevelName); | |
UFUNCTION(BlueprintCallable, Category = "AsyncLevelLoad") | |
void OpenLoadedLevel(); | |
// Streaming | |
UPROPERTY(BlueprintAssignable, Category = "StreamLevelLoad") | |
FOnLevelLoadedDelegate_Streaming OnLevelLoadedDelegate_Streaming; | |
UFUNCTION(BlueprintCallable, Category = "StreamLevelLoad") | |
void StreamLevelLoad(const FString& LevelNameToLoad, const FString& LevelNameToUnload); | |
UFUNCTION() | |
void OnStreamLevelLoaded(); | |
private: | |
FString GetLoadingResultString(EAsyncLoadingResult::Type Result); | |
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; | |
public: | |
// Sets default values for this component's properties | |
UAsyncLevelLoadSceneComponent(); | |
UPROPERTY(BlueprintReadOnly, Category = "AsyncLevelLoad") | |
float loadingPercentage; | |
private: | |
// Async | |
FString pLevelDir; | |
FString pLevelName; | |
EAsyncLoadingResult::Type pResult; | |
bool bIsLoading; | |
// Streaming | |
FString pLevelNameToUnload; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment