Hi all,
I’m trying to follow this tutorial https://impetus-games.com/blog/Persistent-Graphics-Settings-in-UE4
I’ve got my Blueprint library function called UBpVideoSettingsLib as described in the tutorial but I still get a compilation error
I added “RHI” for dependency on my project.build
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class Overrule100 : ModuleRules
{
public Overrule100(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "RHI", "Engine", "InputCore"});
PrivateDependencyModuleNames.AddRange(new string] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
UBpvideoSettingsLib.h
#pragma once
#include “CoreMinimal.h”
#include “Kismet/BlueprintFunctionLibrary.h”
#include “UBpVideoSettingsLib.generated.h”
/**
*
*/
UCLASS()
class OVERRULE100_API UUBpVideoSettingsLib : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
// Get a list of screen resolutions supported on this machine
UFUNCTION(BlueprintPure, Category = "Video Settings")
static bool GetSupportedScreenResolutions(TArray<FString>& Resolutions);
private:
// Try to get the GameUserSettings object from the engine
static UGameUserSettings* GetGameUserSettings();
};
and the UBpVideoSettingsLib.cpp
#include “UBpVideoSettingsLib.h”
UGameUserSettings* UBpVideoSettingsLib::GetGameUserSettings()
{
if (GEngine != nullptr)
{
return GEngine->GameUserSettings;
}
return nullptr;
}
bool UBpVideoSettingsLib::GetSupportedScreenResolutions(TArray<FString>& Resolutions)
{
FScreenResolutionArray ResolutionsArray;
if (RHIGetAvailableResolutions(ResolutionsArray, true)) // "RHI" dependency
{
for (const FScreenResolutionRHI& Resolution : ResolutionsArray)
{
FString StrW = FString::FromInt(Resolution.Width);
FString StrH = FString::FromInt(Resolution.Height);
Resolutions.AddUnique(StrW + "x" + StrH);
}
return true;
}
return false; // failed to obtain screen resolutions
}
Severity Code Description Project File Line Suppression State
Error C2653 ‘UBpVideoSettingsLib’: is not a class or namespace name Overrule100 E:\Overrule 1.0\Source\Overrule100\UBpVideoSettingsLib.cpp 6
Error C2653 ‘UBpVideoSettingsLib’: is not a class or namespace name Overrule100 E:\Overrule 1.0\Source\Overrule100\UBpVideoSettingsLib.cpp 17
Error UBT ERROR: Failed to produce item: E:\Overrule 1.0\Binaries\Win64\UE4Editor-Overrule100.dll Overrule100 E:\Overrule 1.0\Intermediate\ProjectFiles\UnrealBuildTool 1
Error MSB3075 The command ““E:\Program Files (x86)\UE_4.19\Engine\Build\BatchFiles\Build.bat” Overrule100Editor Win64 Development “E:\Overrule 1.0\Overrule100.uproject” -WaitMutex -FromMsBuild” exited with code 5. Please verify that you have sufficient rights to run this command. Overrule100 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets 44
What exactly is the problem?