Можете помочь? При компиляции кода в Unreal Engune 4.27 выходит ошибка:
Строками 9 и 18 являются:
USystemFunctionLibrary::AsyncLevelLoadFinished;
USystemFunctionLibrary::AsyncLevelLoadSystem;
Код:
#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SystemFunctionLibrary.generated.h"

/**
 * 
 */
UCLASS()
class IFIRIMAL_API USystemFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
public:
	UFUNCTION(BlueprintCallable)
	static void AsyncLevelLoadSystem(TArray<FString> LevelName, const FString& LevelPath, int ArrIndex);
private:
	void AsyncLevelLoadFinished();
};
#include "SystemFunctionLibrary.h"
#include "UObject/UObjectGlobals.h"
#include "Kismet/GameplayStatics.h"

void USystemFunctionLibrary::AsyncLevelLoadSystem(TArray<FString> LevelName, const FString& LevelPath, int ArrIndex)
{
	if (LevelName[ArrIndex].IsEmpty())
	{
		USystemFunctionLibrary::AsyncLevelLoadFinished;
	}
	else
	{
		LoadPackageAsync(LevelPath + LevelName[ArrIndex],
			FLoadPackageAsyncDelegate::CreateLambda([=](const FName& PackageName, UPackage* LoadedPackage, EAsyncLoadingResult::Type Result)
				{
					if (Result == EAsyncLoadingResult::Succeeded)
					{
						USystemFunctionLibrary::AsyncLevelLoadSystem;
					}
				}
			),
			PKG_ContainsMap);
	}
	ArrIndex++;
}

void USystemFunctionLibrary::AsyncLevelLoadFinished()
{
	UGameplayStatics::OpenLevel(this, FName("MainLevel"));
}

Accepted answer

Немного переработал код, теперь всё работает.
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "SystemPlayerController.generated.h"

UCLASS()
class IFIRIMAL_API ASystemPlayerController : public APlayerController
{
	GENERATED_BODY()
public:
			UFUNCTION(BlueprintCallable, Category = SystemPlayer)
			void AsyncLevelLoadSystem();
			void AsyncLevelLoadFinished();
public:
			UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = SystemPlayer)
			TArray<FString> LevelsNameArray;
public:
			UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = SystemPlayer)
			FString Path;
			int Index;
};
#include "SystemPlayerController.h"
#include "UObject/UObjectGlobals.h"
#include "Kismet/GameplayStatics.h"

void ASystemPlayerController::AsyncLevelLoadSystem()
{
	if (LevelsNameArray[Index].IsEmpty())
	{
		ASystemPlayerController::AsyncLevelLoadFinished();
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("All Levels Load End"));
	}
	else
	{
		LoadPackageAsync(Path + LevelsNameArray[Index],
			FLoadPackageAsyncDelegate::CreateLambda([=](const FName& PackageName, UPackage* LoadedPackage, EAsyncLoadingResult::Type Result)
				{
					if (Result == EAsyncLoadingResult::Succeeded)
					{
						GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Level Load End"));
						ASystemPlayerController::AsyncLevelLoadSystem();
					}
				}
			),
			PKG_ContainsMap);
		Index++;
	}
}

void ASystemPlayerController::AsyncLevelLoadFinished()
{
	UGameplayStatics::OpenLevel(this, "MainLevel");
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Open MainLevel"));
}
`
LOADING AD...
0
7
11 months ago
0
Нашел в чем причина ошибки, просто перед USystemFunctionLibrary необходимо было поставить &.
Однако при выполнении кода функций AsyncLevelLoadSystem и AsyncLevelLoadFinished не вызываются. Кто-то может подсказать в чем причина?
#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SFunctionLibrary.generated.h"

UCLASS()
class IFIRIMAL_API USFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
public:
	UFUNCTION(BlueprintCallable)
	static void AsyncLevelLoadSystem(TArray<FString> LevelName, const FString& LevelPath, int ArrIndex);
	void AsyncLevelLoadFinished();
};
#include "SFunctionLibrary.h"
#include "UObject/UObjectGlobals.h"
#include "Kismet/GameplayStatics.h"

void USFunctionLibrary::AsyncLevelLoadSystem(TArray<FString> LevelName, const FString& LevelPath, int ArrIndex)
{
	if (LevelName[ArrIndex].IsEmpty())
	{
		&USFunctionLibrary::AsyncLevelLoadFinished;
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("All Levels Load End"));
	}
	else
	{
		LoadPackageAsync(LevelPath + LevelName[ArrIndex],
			FLoadPackageAsyncDelegate::CreateLambda([=](const FName& PackageName, UPackage* LoadedPackage, EAsyncLoadingResult::Type Result)
				{
					if (Result == EAsyncLoadingResult::Succeeded)
					{
						GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Level Load End"));
						&USFunctionLibrary::AsyncLevelLoadFinished;
					}
				}
			),
			PKG_ContainsMap);
		ArrIndex++;
	}
}

void USFunctionLibrary::AsyncLevelLoadFinished()
{
	UGameplayStatics::OpenLevel(this, "MainLevel");
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Open MainLevel"));
}
0
7
11 months ago
0
Немного переработал код, теперь всё работает.
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "SystemPlayerController.generated.h"

UCLASS()
class IFIRIMAL_API ASystemPlayerController : public APlayerController
{
	GENERATED_BODY()
public:
			UFUNCTION(BlueprintCallable, Category = SystemPlayer)
			void AsyncLevelLoadSystem();
			void AsyncLevelLoadFinished();
public:
			UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = SystemPlayer)
			TArray<FString> LevelsNameArray;
public:
			UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = SystemPlayer)
			FString Path;
			int Index;
};
#include "SystemPlayerController.h"
#include "UObject/UObjectGlobals.h"
#include "Kismet/GameplayStatics.h"

void ASystemPlayerController::AsyncLevelLoadSystem()
{
	if (LevelsNameArray[Index].IsEmpty())
	{
		ASystemPlayerController::AsyncLevelLoadFinished();
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("All Levels Load End"));
	}
	else
	{
		LoadPackageAsync(Path + LevelsNameArray[Index],
			FLoadPackageAsyncDelegate::CreateLambda([=](const FName& PackageName, UPackage* LoadedPackage, EAsyncLoadingResult::Type Result)
				{
					if (Result == EAsyncLoadingResult::Succeeded)
					{
						GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Level Load End"));
						ASystemPlayerController::AsyncLevelLoadSystem();
					}
				}
			),
			PKG_ContainsMap);
		Index++;
	}
}

void ASystemPlayerController::AsyncLevelLoadFinished()
{
	UGameplayStatics::OpenLevel(this, "MainLevel");
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Open MainLevel"));
}
Accepted answer
To leave a comment please sign in to the site.