当游戏开始时,游戏会自动从下面的目录中读取用户设置。后一个文件的配置将覆盖前一个的配置
当保存设置时, 将是在[ProjectDirectory]/Saved/Config/[Platform]/GameUserSettings.ini 中保存设置。
Engine/Config/Base.ini
Base.ini通常是空的。
Engine/Config/BaseGameUserSettings.ini
Engine/Config/[Platform]/[Platform]GameUserSettings.ini
[ProjectDirectory]/Config/DefaultGameUserSettings.ini
[ProjectDirectory]/Config/[Platform]/[Platform]GameUserSettings.ini
[ProjectDirectory]/Saved/Config/[Platform]/GameUserSettings.ini
“已保存”目录中的配置文件仅在配置文件堆栈中存储特定于项目和特定于平台的差异。
如果是在编辑器中运行的话,(包括这里显示的这几项 ),ProjectDirectory就是项目所在目录。如果是运行于,则ProjectDirectory是临时的,当ue4编辑器关闭后失效。
如果是在游戏中运行的话,ProjectDirectory目录就是游戏所在目录,不过对于6中的saved目录,windwos的 shipping版Saved目录在C:\Users\Administrator\AppData\Local\Project\下而其他模式下则在项目目录下。
当使用各种模式设置功能时,不会立即应用该模式,就像您在PC游戏设置菜单中所期望的那样。相反,该值将保存到游戏配置中,直到你调用相应地应用函数。
对于分辨率和全屏模式的设置,使用ApplyResolutionSetting来应用你的设置,其中参数bCheckForCommandLineOverrides 是 用来说明 是否使用命令行参数(不是控制台参数)来覆盖当前设置的分辨率和全屏模式。通常我们使用false
在调用该函数前,通常需要我们调用ConfirmVideoMode 来保存用户确认将要使用的分辨率和全屏模式。
(ConfirmVideoMode 函数会将当前保存在设置中的准备使用的分辨率和全屏模式保存在对应的lastConfiremed开头的变量中。如果不使用ConfirmVideoMode 保存地话,当我们调用ResetToCurrentSettings后,该函数将把lastConfirmed设置为当前的分辨率和全屏模式,这将导致现在真正使用的分辨率并没有正确的反映再设置中,调用getScreenResolution或者保存设置时,就会返回错误分辨率)
对于分辨率和全屏模式的设置,常用的函数有如下
ApplyResolutionSettings(boolbCheckForCommandLineOverrides);
/** 应用分辨率和全屏模式的设置*/
ConfirmVideoMode();
/** 将现在的(fullscreenmode/resolution)设置 作为用户确认的设置*/
RevertVideoMode();
/** 将现在的(fullscreenmode/resolution)设置 修改成之前用户确认的设置*/
分辨率
GetDefaultResolution()
/** 获取默认分辨率 返回的是0,0*/
IsScreenResolutionDirty()
/** 检测当前的用户设置分辨率是否与现在真正的的屏幕分辨率不同*/
GetScreenResolution()
/** 返回用户设置的屏幕分辨率, 单位是像素.*/ 注意 全屏分辨率的设置,必须是GetSupportedFullscreenResolutions 中的一个,否则UI会出问题
GetLastConfirmedScreenResolution()
/** 返回用户设置的最后确认的屏幕分辨率, 单位是像素*/
GetDesktopResolution()
/** 返回桌面分辨率,这个是跟你windwos设置的桌面分辨率有关,单位是像素*/
SetScreenResolution(FIntPointResolution);
/** 设置屏幕分辨率.*/
全屏模式
GetDefaultWindowMode()
/** 获取默认全屏模式,返回windowedFullScreen*/
IsFullscreenModeDirty()
/** 检测当前的用户设置全屏模式是否与现在真正的全屏模式不同*/
GetFullscreenMode()
/**返回用户设置的全屏模式. */
/**
*Gamewindowfullscreenmode
* 0=Fullscreen// 全屏
* 1=WindowedFullscreen//无边框窗口全屏
* 2=Windowed//有边框的窗口模式
*/
GetLastConfirmedFullscreenMode()
/** 返回用户设置的最后确认的全屏模式*/
SetFullscreenMode(EWindowMode::TypeInFullscreenMode);
/** 设置全屏模式.*/
GetPreferredFullscreenMode()
/** 返回合适的全屏模式.*/
还有两个不是GameUserSetting的分辨率常用函数
GetSupportedFullscreenResolutions
获取支持全屏分辨率的列表(Fullscreen, 不适用WindowedFullscreen, WindowedFullscreen 直接用GetDesktopResolution去获得就可以了)。如成功查询到可用分辨率的设备,则返回true,
GetConvenientWindowedResolutions
获取适用于当前主显示尺寸的窗口化分辨率的列表。如成功查询到可用分辨率的设备,则返回true
对于其他的设置,使用ApplyNonResolutionSetting来应用你的设置。
ApplyNonResolutionSettings();
/** 应用所有非分辨率和全屏模式的设置*/
帧率
SetFrameRateLimit(floatNewLimit);
/** 设置游戏帧率限制(相当于t.maxfps)(0或者小于0将取消帧率限制,这里有问题,测试中0或者小于0的帧率为60帧)*/
GetFrameRateLimit()const;
/** 获取游戏帧率限制*/
垂直同步
SetVSyncEnabled(boolbEnable);
/** 设置是否开启垂直同步(锁帧屏幕刷新)*/
IsVSyncEnabled()const;
/** 返回垂直同步是否开启.*/
IsVSyncDirty()const;
/** 检测用户设置的垂直同步是否与现在的真正系统设置相同*/
GetSyncInterval()
/** 获得垂直同步间隔*/
动态分辨率
SetDynamicResolutionEnabled(boolbEnable);
/** 设置是否开启动态分辨率.*/
IsDynamicResolutionEnabled()const;
/** 返回是否开启动态分辨率.*/
IsDynamicResolutionDirty()const;
/** 检测用户设置的是否开启动态分辨率与真正的系统设置是否相同*/
音频质量
SetAudioQualityLevel(int32QualityLevel);
/** 设置音频的质量*/
GetAudioQualityLevel()const{returnAudioQualityLevel;}
/** 返回用户设置的音频质量*/
可扩展设置
SetOverallScalabilityLevel(int32Value);
// 设置所有可扩展设置的等级
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic
GetOverallScalabilityLevel()const;
// 返回所有可扩展设置的等级(如果所有可扩展设置等级不相同将返回-1)
GetResolutionScaleInformationEX(float&CurrentScaleNormalized,float&CurrentScaleValue,float&MinScaleValue,float&MaxScaleValue)
// 返回当前的分辨率缩放和缩放范围
SetResolutionScaleValueEx(floatNewScaleValue);
// 设置当前的分辨率缩放
SetResolutionScaleNormalized(floatNewScaleNormalized);
// 设置当前的分辨率缩放,以0-1表示最大和最小值
SetViewDistanceQuality(int32Value);
// 设置视野距离质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic(getsclampedifneeded)
GetViewDistanceQuality()const;
//Returnstheviewdistancequality(0..4,higherisbetter)
SetShadowQuality(int32Value);
// 设置阴影质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic(getsclampedifneeded)
GetShadowQuality()const;
//Returnstheshadowquality(0..4,higherisbetter)
SetAntiAliasingQuality(int32Value);
// 设置抗锯齿质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic(getsclampedifneeded)
GetAntiAliasingQuality()const;
//Returnstheanti-aliasingquality(0..4,higherisbetter)
SetTextureQuality(int32Value);
// 设置纹理质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic (getsclampedifneeded)
GetTextureQuality()const;
//Returnsthetexturequality(0..4,higherisbetter)
SetVisualEffectQuality(int32Value);
// 设置可视效果质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic(getsclampedifneeded)
GetVisualEffectQuality()const;
//Returnsthevisualeffectsquality(0..4,higherisbetter)
SetPostProcessingQuality(int32Value);
// 设置后处理效果质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic(getsclampedifneeded)
GetPostProcessingQuality() const;
//Returnsthepost-processingquality(0..4,higherisbetter)
SetFoliageQuality(int32Value);
// 设置植被显示质量(0..4,higherisbetter)
//@paramValue0:low,1:medium,2:high,3:epic,4:cinematic(getsclampedifneeded)
GetFoliageQuality()const;
//Returnsthefoliagequality(0..4,higherisbetter)
要应用所有设置并保存,使用ApplySettings
/** 应用所有现在的用户设置,并保存到配置文件*/
virtualvoidApplySettings(boolbCheckForCommandLineOverrides);
要保存所有设置,使用SaveSettings
其他的常用函数有如下
ApplySettings(boolbCheckForCommandLineOverrides)
/** 应用所有现在的用户设置,并保存到配置文件*/
IsDirty()
/** 检测用户设置是否跟当前系统设置不同*/
ValidateSettings();
/** 验证用户设置,将错误的用户设置(比如设置分辨率是负值)重置为默认*/
LoadSettings(boolbForceReload=false);
/** 从持久化存储(ini文件中)加载用户设置 */
SaveSettings();
/** 存储用户设置到持久化存储,作为ApplySetting的一部分自动执行*/
ResetToCurrentSettings();
/**将用户设置重置成当前系统设置,分辨率重置成lastConfirmed*/
SetToDefaults();
/**将用户设置重置成默认设置
GetDefaultWindowPosition()
/**返回默认窗口位置,返回-1,-1*/
/**GetsthedesiredresolutionqualitybasedonDesiredScreenWidth/Heightandthecurrentscreenresolution*/
virtualfloatGetDefaultResolutionScale();
/**GetstherecommendedresolutionqualitybasedonLastRecommendedScreenWidth/Heightandthecurrentscreenresolution*/
virtualfloatGetRecommendedResolutionScale();
/**Returnsthegamelocalmachinesettings(resolution,windowingmode,scalabilitysettings,etc...)*/
staticUGameUserSettings*GetGameUserSettings();
/**RunsthehardwarebenchmarkandpopulatesScalabilityQualityaswellasthelastbenchmarkresultsconfigmembers,butdoesnotapplythesettingsitdetermines.DesignedtobecalledinconjunctionwithApplyHardwareBenchmarkResults*/
virtualvoidRunHardwareBenchmark(int32WorkScale=10,floatCPUMultiplier=1.0f,floatGPUMultiplier=1.0f);
/**AppliesthesettingsstoredinScalabilityQualityandsavessettings*/
virtualvoidApplyHardwareBenchmarkResults();
/**WhetherthecurentlyrunningsystemsupportsHDRdisplayoutput*/
virtualboolSupportsHDRDisplayOutput()const;
/**EnablesordisablesHDRdisplayoutput.Canbecalledagaintochangethedesirednitlevel*/
voidEnableHDRDisplayOutput(boolbEnable,int32DisplayNits=1000);
/**Returns0ifHDRisn'tsupportedoristurnedoff*/
int32GetCurrentHDRDisplayNits()const;
boolIsHDREnabled()const;