# Custom GameUserSettings

**URL:** <https://forums.unrealengine.com/t/custom-gameusersettings/1791586>\
**Category:** C++\
**Tags:** unreal-engine, question, CPP\
**Created:** [April 6, 2024, 11:14pm UTC](https://forums.unrealengine.com/t/custom-gameusersettings/1791586 "2024-04-06T23:14:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 7, 2024, 1:30pm UTC](https://forums.unrealengine.com/t/custom-gameusersettings/1791586/2 "2024-04-07T13:30:25Z")

</div>

> [@Lizzzyl](#):
>
> AntiAliasingMethod

.h

```auto

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameUserSettings.h"
#include "GameUserSettingsExtended.generated.h"

/**
 * 
 */
UCLASS(config = GameUserSettings, configdonotcheckdefaults, Blueprintable)
class YOUR_API UGameUserSettingsExtended : public UGameUserSettings
{
	GENERATED_BODY()

public:

	UGameUserSettingsExtended(const FObjectInitializer& ObjectInitializer);

	// Sets the anti-aliasing method 
	// @param Value 0:none, 1:FXAA, 2:TAA, 3:MSAA, 4:TSR 
	UFUNCTION(BlueprintCallable, Category = Settings)
	void SetAntiAliasingMethod(EAntiAliasingMethod Value);

	// Returns the anti-aliasing method 
	UFUNCTION(BlueprintCallable, Category = Settings)
	EAntiAliasingMethod GetAntiAliasingMethod();

	UPROPERTY(config)
	uint8 AntiAliasingMethod;

	UFUNCTION(BlueprintPure, Category = Settings)
	bool IsAntiAliasingMethodDirty() const;

	//UFUNCTION(BlueprintCallable, Category = Settings)
	virtual void LoadSettings(bool bForceReload = false) override;
};

```

.cpp

```auto
#include "GameUserSettingsExtended.h"
#include "Kismet/GameplayStatics.h"

UGameUserSettingsExtended::UGameUserSettingsExtended(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{	
	SetToDefaults();	
}

void UGameUserSettingsExtended::SetAntiAliasingMethod(EAntiAliasingMethod Value)
{		
	static IConsoleVariable* SetAA = IConsoleManager::Get().FindConsoleVariable(TEXT("r.AntiAliasingMethod"));
	if (ensure(SetAA))
	{
		// ECVF_SetByGameSetting , ECVF_SetByCode, ECVF_SetByProjectSetting
		SetAA->Set((uint8)Value, ECVF_SetByGameSetting);
		SetAA->Set((uint8)Value, ECVF_SetByProjectSetting);
	}	
	UWorld* world = GEngine->GameViewport->GetWorld();
	//UWorld* w = GetWorld();
	if (world != nullptr) {
		if (APlayerController* PC = UGameplayStatics::GetPlayerController(world, 0)) {
			PC->ConsoleCommand("r.AntiAliasingMethod " + (int32)Value);
		}
	}
	AntiAliasingMethod = (uint8)Value;
}

EAntiAliasingMethod UGameUserSettingsExtended::GetAntiAliasingMethod()
{
	static IConsoleVariable* GetAA = IConsoleManager::Get().FindConsoleVariable(TEXT("r.AntiAliasingMethod"));		
	if (ensure(GetAA))
	{
		AntiAliasingMethod = (uint8)GetAA->GetInt();
	}		
	return (EAntiAliasingMethod)AntiAliasingMethod;
}

bool UGameUserSettingsExtended::IsAntiAliasingMethodDirty() const
{
	bool bIsDirty = false;
	if (GEngine && GEngine->GameViewport && GEngine->GameViewport->ViewportFrame)
	{
		static IConsoleVariable* GetAA = IConsoleManager::Get().FindConsoleVariable(TEXT("r.AntiAliasingMethod"));
		int32 aa = (uint8)GetAA->GetInt();
		bIsDirty = (AntiAliasingMethod != aa);
	}
	return bIsDirty;
}

void UGameUserSettingsExtended::LoadSettings(bool bForceReload)
{
	Super::LoadSettings(bForceReload);
	static IConsoleVariable* GetAA = IConsoleManager::Get().FindConsoleVariable(TEXT("r.AntiAliasingMethod"));
	if (ensure(GetAA))
	{
		AntiAliasingMethod = (uint8)GetAA->GetInt();
	}
	ApplyNonResolutionSettings();
}

```

 ![cast1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/9/16958bceeb3723457f5e8332c39e9b0fdf7e5e32.png)  
 ![cast2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/5/f35189a905f24c83ed2e17d8ef135ff528ad5ef1.png)

---

_[View the full topic](https://forums.unrealengine.com/t/custom-gameusersettings/1791586)._
