gameplay所有基本功能都装了,加入了全局警告。加入飘字等各种东西。
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -9,6 +11,7 @@ public class graphicSettings : MonoBehaviour
|
||||
public Dropdown screenMode_Dropdown;
|
||||
public Dropdown resolution_Dropdown;
|
||||
public Dropdown frameRate_Dropdown;
|
||||
public Toggle superResolution_Toggle;
|
||||
|
||||
public Image resolutionLock_Image;
|
||||
|
||||
@@ -16,11 +19,14 @@ public class graphicSettings : MonoBehaviour
|
||||
private int tempFreeResOptionIndex = -1;
|
||||
private Vector2Int lastScreenSize;
|
||||
|
||||
private const string PREF_SUPER_RES = "SuperResolution";
|
||||
|
||||
void Start()
|
||||
{
|
||||
InitScreenModeDropdown();
|
||||
InitResolutionDropdown();
|
||||
InitFrameRateDropdown();
|
||||
InitSuperResolutionToggle();
|
||||
lastScreenSize = new Vector2Int(Screen.width, Screen.height);
|
||||
}
|
||||
|
||||
@@ -32,6 +38,8 @@ public class graphicSettings : MonoBehaviour
|
||||
resolution_Dropdown.onValueChanged.RemoveListener(OnResolutionChanged);
|
||||
if (frameRate_Dropdown != null)
|
||||
frameRate_Dropdown.onValueChanged.RemoveListener(OnFrameRateChanged);
|
||||
if (superResolution_Toggle != null)
|
||||
superResolution_Toggle.onValueChanged.RemoveListener(OnSuperResolutionChanged);
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -444,6 +452,38 @@ public class graphicSettings : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSuperResolutionToggle()
|
||||
{
|
||||
// Default is OFF (0).
|
||||
bool isOn = PlayerPrefs.GetInt(PREF_SUPER_RES, 0) == 1;
|
||||
|
||||
// Apply setting immediately to ensure correct render scale state
|
||||
// even if the toggle UI is missing or not assigned yet.
|
||||
ApplySuperResolution(isOn);
|
||||
|
||||
if (superResolution_Toggle != null)
|
||||
{
|
||||
superResolution_Toggle.isOn = isOn;
|
||||
superResolution_Toggle.onValueChanged.AddListener(OnSuperResolutionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSuperResolutionChanged(bool isOn)
|
||||
{
|
||||
PlayerPrefs.SetInt(PREF_SUPER_RES, isOn ? 1 : 0);
|
||||
PlayerPrefs.Save();
|
||||
ApplySuperResolution(isOn);
|
||||
}
|
||||
|
||||
private void ApplySuperResolution(bool isOn)
|
||||
{
|
||||
var urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
if (urpAsset != null)
|
||||
{
|
||||
urpAsset.renderScale = isOn ? 2.0f : 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
Reference in New Issue
Block a user