中
This commit is contained in:
@@ -8,10 +8,9 @@ using YooAsset;
|
||||
|
||||
public class GraphicsManager : Singleton<GraphicsManager>
|
||||
{
|
||||
public GraphicsSetting graphicsSetting;
|
||||
private UniversalRenderPipelineAsset _urpAsset;
|
||||
private VolumeProfile urpVolumeProfile;
|
||||
public GraphicsManager()
|
||||
public void Init()
|
||||
{
|
||||
_urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
|
||||
@@ -24,17 +23,50 @@ public class GraphicsManager : Singleton<GraphicsManager>
|
||||
{
|
||||
Debug.LogError("VolumeProfile null");
|
||||
}
|
||||
graphicsSetting = SettingsManager.Inst.CurrentSettings.graphicsSettings;
|
||||
ApplySettings();
|
||||
}
|
||||
public void ApplySettings()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings = graphicsSetting;
|
||||
GraphicsSetting graphicsSetting = SettingsManager.Inst.CurrentSettings.graphicsSettings;
|
||||
SettingsManager.Inst.SaveSettings();
|
||||
ApplySetURPAsset(graphicsSetting);
|
||||
ApplySetResolution(graphicsSetting);
|
||||
ApplySetDisplay(graphicsSetting);
|
||||
}
|
||||
void ApplySetURPAsset(GraphicsSetting graphicsSetting)
|
||||
{
|
||||
QualitySettings.vSyncCount = graphicsSetting.vsyncEnabled ? 1 : 0;
|
||||
_urpAsset.shadowDistance = graphicsSetting.shadowDistance;
|
||||
_urpAsset.msaaSampleCount = (int)Mathf.Pow(2, graphicsSetting.qualityLevel);
|
||||
_urpAsset.renderScale = graphicsSetting.renderScale;
|
||||
}
|
||||
void ApplySetResolution(GraphicsSetting graphicsSetting)
|
||||
{
|
||||
if (Screen.resolutions == null) return;
|
||||
Resolution res = Screen.resolutions[Screen.resolutions.Length - 1];
|
||||
if (graphicsSetting.resolutionIndex < Screen.resolutions.Length && graphicsSetting.resolutionIndex >= 0)
|
||||
{
|
||||
res = Screen.resolutions[graphicsSetting.resolutionIndex];
|
||||
}
|
||||
|
||||
FullScreenMode mode = graphicsSetting.borderless ?
|
||||
FullScreenMode.FullScreenWindow :
|
||||
(graphicsSetting.fullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed);
|
||||
|
||||
Screen.SetResolution(
|
||||
res.width,
|
||||
res.height,
|
||||
mode,
|
||||
res.refreshRateRatio
|
||||
);
|
||||
}
|
||||
void ApplySetDisplay(GraphicsSetting graphicsSetting)
|
||||
{
|
||||
if (graphicsSetting.displayIndex > 0 && graphicsSetting.displayIndex < Display.displays.Length)
|
||||
{
|
||||
Display.displays[graphicsSetting.displayIndex].Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public class GraphicsSetting
|
||||
@@ -47,6 +79,11 @@ public class GraphicsSetting
|
||||
public float renderScale = 1.0f;
|
||||
public bool isCustom = false;
|
||||
|
||||
public int resolutionIndex = 0;
|
||||
public bool fullscreen = true;
|
||||
public bool borderless = false;
|
||||
public int displayIndex = 0;
|
||||
|
||||
public GraphicsSetting() { }
|
||||
|
||||
public GraphicsSetting(int quality, bool vsync, float shadows, int aa, bool bloom, float scale)
|
||||
|
||||
Reference in New Issue
Block a user