ue4 GameUserSetting的使用(设置分辨率,全屏模式,帧率,垂直同步等)

您所在的位置:网站首页 ue引擎是什么意思 ue4 GameUserSetting的使用(设置分辨率,全屏模式,帧率,垂直同步等)

ue4 GameUserSetting的使用(设置分辨率,全屏模式,帧率,垂直同步等)

2023-10-26 05:05| 来源: 网络整理| 查看: 265

当游戏开始时,游戏会自动从下面的目录中读取用户设置。后一个文件的配置将覆盖前一个的配置

当保存设置时, 将是在[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(bool bCheckForCommandLineOverrides);

/** 应用分辨率和全屏模式的设置*/

ConfirmVideoMode();

/** 将现在的(fullscreenmode/resolution)设置 作为用户确认的设置*/

RevertVideoMode();

/** 将现在的 (fullscreenmode/resolution)设置 修改成之前用户确认的设置*/

分辨率

 

GetDefaultResolution()

/** 获取默认分辨率 返回的是0,0*/

IsScreenResolutionDirty()

/** 检测当前的用户设置分辨率是否与现在真正的的屏幕分辨率不同 */

GetScreenResolution()

/** 返回用户设置的屏幕分辨率, 单位是像素. */ 注意 全屏分辨率的设置,必须是GetSupportedFullscreenResolutions 中的一个,否则UI会出问题

GetLastConfirmedScreenResolution()

/** 返回用户设置的最后确认的屏幕分辨率, 单位是像素 */

GetDesktopResolution()

/** 返回桌面分辨率,这个是跟你windwos设置的桌面分辨率有关,单位是像素 */

SetScreenResolution(FIntPoint Resolution);

/** 设置屏幕分辨率. */

全屏模式

 

GetDefaultWindowMode()

/** 获取默认全屏模式,返回windowedFullScreen */

IsFullscreenModeDirty()

/** 检测当前的用户设置全屏模式是否与现在真正的全屏模式不同 */

GetFullscreenMode()

/** 返回用户设置的全屏模式.  */

 /**

     * Game window fullscreen mode

     *    0 = Fullscreen// 全屏

     *    1 = WindowedFullscreen//无边框窗口全屏

     *    2 = Windowed//有边框的窗口模式

     */

GetLastConfirmedFullscreenMode()

/** 返回用户设置的最后确认的全屏模式 */

SetFullscreenMode(EWindowMode::Type InFullscreenMode);

/** 设置全屏模式. */

GetPreferredFullscreenMode() 

/** 返回合适的全屏模式. */

 

 

还有两个不是GameUserSetting的分辨率常用函数

 

GetSupportedFullscreenResolutions

获取支持全屏分辨率的列表(Fullscreen, 不适用WindowedFullscreen, WindowedFullscreen 直接用GetDesktopResolution去获得就可以了)。如成功查询到可用分辨率的设备,则返回true,

GetConvenientWindowedResolutions

获取适用于当前主显示尺寸的窗口化分辨率的列表。如成功查询到可用分辨率的设备,则返回true

 

对于其他的设置,使用ApplyNonResolutionSetting来应用你的设置。

 

ApplyNonResolutionSettings();

/** 应用所有非分辨率和全屏模式的设置*/

帧率

 

SetFrameRateLimit(float NewLimit);

/** 设置游戏帧率限制(相当于t.maxfps) (0或者小于0 将取消帧率限制,这里有问题,测试中0或者小于0的帧率为60帧) */

GetFrameRateLimit() const;

/** 获取游戏帧率限制*/

垂直同步

 

SetVSyncEnabled(bool bEnable);

/** 设置是否开启垂直同步(锁帧屏幕刷新) */

IsVSyncEnabled() const;

/** 返回垂直同步是否开启. */

IsVSyncDirty() const;

/** 检测用户设置的垂直同步是否与现在的真正系统设置相同 */

GetSyncInterval()

/** 获得垂直同步间隔 */

动态分辨率

 

SetDynamicResolutionEnabled(bool bEnable);

/** 设置是否开启动态分辨率. */

IsDynamicResolutionEnabled() const;

/** 返回是否开启动态分辨率. */

IsDynamicResolutionDirty() const;

/** 检测用户设置的是否开启动态分辨率 与真正的系统设置是否相同*/

音频质量

 

SetAudioQualityLevel(int32 QualityLevel);

/** 设置音频的质量*/

GetAudioQualityLevel() const { return AudioQualityLevel; }

/** 返回用户设置的音频质量 */

可扩展设置

 

SetOverallScalabilityLevel(int32 Value);

// 设置所有可扩展设置的等级

// @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic

GetOverallScalabilityLevel() const;

// 返回所有可扩展设置的等级(如果所有可扩展设置等级不相同将返回-1)

GetResolutionScaleInformationEX(float& CurrentScaleNormalized, float& CurrentScaleValue, float& MinScaleValue, float& MaxScaleValue)

// 返回当前的分辨率缩放和缩放范围

SetResolutionScaleValueEx(float NewScaleValue);

// 设置当前的分辨率缩放

SetResolutionScaleNormalized(float NewScaleNormalized);

// 设置当前的分辨率缩放,以0-1表示最大和最小值

SetViewDistanceQuality(int32 Value);

       // 设置视野距离质量 (0..4, higher is better)

       // @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic (gets clamped if needed)

GetViewDistanceQuality() const;

// Returns the view distance quality (0..4, higher is better)

SetShadowQuality(int32 Value);

       // 设置阴影质量 (0..4, higher is better)

       // @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic (gets clamped if needed)

GetShadowQuality() const;

// Returns the shadow quality (0..4, higher is better)

SetAntiAliasingQuality(int32 Value);

// 设置抗锯齿质量 (0..4, higher is better)

       // @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic (gets clamped if needed)

GetAntiAliasingQuality() const;

// Returns the anti-aliasing quality (0..4, higher is better)

SetTextureQuality(int32 Value);

// 设置纹理质量(0..4, higher is better)

       // @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic  (gets clamped if needed)

GetTextureQuality() const;

// Returns the texture quality (0..4, higher is better)

SetVisualEffectQuality(int32 Value);

 // 设置可视效果质量 (0..4, higher is better)

       // @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic (gets clamped if needed)

GetVisualEffectQuality() const;

// Returns the visual effects quality (0..4, higher is better)

SetPostProcessingQuality(int32 Value);

// 设置后处理效果质量 (0..4, higher is better)

// @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic (gets clamped if needed)

GetPostProcessingQuality() const;

// Returns the post-processing quality (0..4, higher is better)

SetFoliageQuality(int32 Value);

// 设置植被显示质量 (0..4, higher is better)

       // @param Value 0:low, 1:medium, 2:high, 3:epic, 4:cinematic (gets clamped if needed)

GetFoliageQuality() const;

// Returns the foliage quality (0..4, higher is better)

要应用所有设置并保存,使用ApplySettings

        /** 应用所有现在的用户设置,并保存到配置文件*/

       virtual void ApplySettings(bool bCheckForCommandLineOverrides);

要保存所有设置,使用SaveSettings

其他的常用函数有如下

ApplySettings(bool bCheckForCommandLineOverrides)

/** 应用所有现在的用户设置,并保存到配置文件*/

IsDirty()

/** 检测用户设置是否跟当前系统设置不同 */

ValidateSettings();

/** 验证用户设置,将错误的用户设置(比如设置分辨率是负值)重置为默认 */

LoadSettings(bool bForceReload = false);

/** 从持久化存储(ini文件中)加载用户设置  */

SaveSettings();

/** 存储用户设置到持久化存储 ,作为ApplySetting的一部分自动执行*/

ResetToCurrentSettings();

/**将用户设置重置成当前系统设置,分辨率重置成lastConfirmed */

SetToDefaults();

/**将用户设置重置成默认设置

GetDefaultWindowPosition()

/**返回默认窗口位置,返回-1,-1 */

 

 

 

       /** Gets the desired resolution quality based on DesiredScreenWidth/Height and the current screen resolution */

       virtual float GetDefaultResolutionScale();

       /** Gets the recommended resolution quality based on LastRecommendedScreenWidth/Height and the current screen resolution */

       virtual float GetRecommendedResolutionScale();

       /** Returns the game local machine settings (resolution, windowing mode, scalability settings, etc...) */

       static UGameUserSettings* GetGameUserSettings();

       /** Runs the hardware benchmark and populates ScalabilityQuality as well as the last benchmark results config members, but does not apply the settings it determines. Designed to be called in conjunction with ApplyHardwareBenchmarkResults */

       virtual void RunHardwareBenchmark(int32 WorkScale = 10, float CPUMultiplier = 1.0f, float GPUMultiplier = 1.0f);

       /** Applies the settings stored in ScalabilityQuality and saves settings */

       virtual void ApplyHardwareBenchmarkResults();

       /** Whether the curently running system supports HDR display output */

       virtual bool SupportsHDRDisplayOutput() const;

       /** Enables or disables HDR display output. Can be called again to change the desired nit level */

       void EnableHDRDisplayOutput(bool bEnable, int32 DisplayNits = 1000);

       /** Returns 0 if HDR isn't supported or is turned off */

       int32 GetCurrentHDRDisplayNits() const;

       bool IsHDREnabled() const;

 

 

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3