UI框架开发中
This commit is contained in:
@@ -126,7 +126,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7736143046250787917}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3}
|
||||
m_Name:
|
||||
|
||||
@@ -9,7 +9,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9156766140375124690}
|
||||
- component: {fileID: 38952591794927206}
|
||||
m_Layer: 0
|
||||
m_Name: UIManager
|
||||
m_TagString: Untagged
|
||||
@@ -32,15 +31,3 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &38952591794927206
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9144517237380066900}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2d1ed5819e87e0f4ebbdf4dad51fcb7a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
|
||||
@@ -132,11 +132,6 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1568052019122780073, guid: 2257ed29939b08f48a2886709375ae69,
|
||||
type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4760332684612964771, guid: 2257ed29939b08f48a2886709375ae69,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
||||
@@ -5371,10 +5371,10 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 4d6ce7fe9c8bcb144bfed87170589a6e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
generalPanel: {fileID: 4929832501435178744}
|
||||
audioPanel: {fileID: 2478601437905449858}
|
||||
graphicsPanel: {fileID: 7082806397231928786}
|
||||
displayPanel: {fileID: 6551384662084563704}
|
||||
generalPanel: {fileID: 4535673477861328621}
|
||||
audioPanel: {fileID: 3733547730907787236}
|
||||
graphicsPanel: {fileID: 41461428167766573}
|
||||
displayPanel: {fileID: 561068071673071071}
|
||||
generalTab: {fileID: 2750116641401440055}
|
||||
audioTab: {fileID: 1661438359137702215}
|
||||
graphicsTab: {fileID: 5210410202606032641}
|
||||
|
||||
@@ -15,14 +15,14 @@ public class ScreenTest : MonoBehaviour
|
||||
startPos = ParentObj.anchoredPosition;
|
||||
inputAction.action.Enable();
|
||||
inputAction.action.performed += ScreenTouchTest;
|
||||
onScreenStick.onPointerDown += () =>
|
||||
{
|
||||
ParentObj.anchoredPosition = onScreenStick.PointerDownPos;
|
||||
};
|
||||
onScreenStick.onPointerUp += () =>
|
||||
{
|
||||
ParentObj.anchoredPosition = startPos;
|
||||
};
|
||||
//onScreenStick.onPointerDown += () =>
|
||||
//{
|
||||
// ParentObj.anchoredPosition = onScreenStick.PointerDownPos;
|
||||
//};
|
||||
//onScreenStick.onPointerUp += () =>
|
||||
//{
|
||||
// ParentObj.anchoredPosition = startPos;
|
||||
//};
|
||||
}
|
||||
|
||||
private void ScreenTouchTest(InputAction.CallbackContext obj)
|
||||
|
||||
@@ -6,13 +6,32 @@ using YooAsset;
|
||||
public class GameStart : MonoBehaviour
|
||||
{
|
||||
SceneHandle sceneHandle;
|
||||
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
StartCoroutine(LoadScene());
|
||||
//StartCoroutine(LoadUIManager());
|
||||
StartCoroutine(StartupSequence());
|
||||
}
|
||||
IEnumerator LoadScene()
|
||||
|
||||
IEnumerator StartupSequence()
|
||||
{
|
||||
Debug.Log("<22><>ʼ<EFBFBD><CABC>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
||||
|
||||
yield return StartCoroutine(InitializeGameSystems());
|
||||
|
||||
yield return StartCoroutine(LoadMainScene());
|
||||
|
||||
Debug.Log("<22><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
|
||||
IEnumerator InitializeGameSystems()
|
||||
{
|
||||
Debug.Log("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Ϸϵͳ...");
|
||||
GameSystem.Inst.Init();
|
||||
Debug.Log("<22><>Ϸϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
yield return null;
|
||||
}
|
||||
IEnumerator LoadMainScene()
|
||||
{
|
||||
sceneHandle = YooAssets.LoadSceneAsync("MirrorRoomOffline");
|
||||
//sceneHandle = YooAssets.LoadSceneAsync("Game");
|
||||
@@ -23,17 +42,6 @@ public class GameStart : MonoBehaviour
|
||||
};
|
||||
yield return sceneHandle;
|
||||
}
|
||||
//IEnumerator LoadUIManager()
|
||||
//{
|
||||
// AssetHandle _handle = YooAssets.LoadAssetAsync<GameObject>("UIManager");
|
||||
// _handle.Completed += (handle) =>
|
||||
// {
|
||||
// GameObject go = Instantiate((GameObject)_handle.AssetObject);
|
||||
// DontDestroyOnLoad(go);
|
||||
// Debug.Log(_handle.AssetObject);
|
||||
// };
|
||||
// yield return _handle;
|
||||
//}
|
||||
IEnumerator LoadNetWorkHUD()
|
||||
{
|
||||
AssetHandle _handle = YooAssets.LoadAssetAsync<GameObject>("MyNetWorkHUD");
|
||||
@@ -44,12 +52,4 @@ public class GameStart : MonoBehaviour
|
||||
};
|
||||
yield return _handle;
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//if(sceneHandle!=null && sceneHandle.IsValid)
|
||||
//{
|
||||
// Debug.Log(sceneHandle.Progress);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
18
Assets/Scripts/HotUpdate/Main/GameSystem.cs
Normal file
18
Assets/Scripts/HotUpdate/Main/GameSystem.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameSystem : Singleton<GameSystem>
|
||||
{
|
||||
public UIManager UI { get; private set; }
|
||||
public SettingsManager Settings { get; private set; }
|
||||
|
||||
public GraphicsManager Graphics { get; private set; }
|
||||
public void Init()
|
||||
{
|
||||
UI = UIManager.Inst;
|
||||
Settings = SettingsManager.Inst;
|
||||
Graphics = GraphicsManager.Inst;
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/HotUpdate/Main/GameSystem.cs.meta
Normal file
11
Assets/Scripts/HotUpdate/Main/GameSystem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f34cd41201fbe34d9c5cb62ffabda99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -119,16 +119,16 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
|
||||
if (!isLocalPlayer) return;
|
||||
if (context.performed)
|
||||
{
|
||||
//isCursorLocked = SettingsManager.Inst.isShow();
|
||||
//UpdateCursorState();
|
||||
//if (SettingsManager.Inst.isShow())
|
||||
//{
|
||||
// SettingsManager.Inst.CloseSettingWindow();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SettingsManager.Inst.OpenSettingWindow();
|
||||
//}
|
||||
isCursorLocked = !isCursorLocked;
|
||||
UpdateCursorState();
|
||||
if (GameSystem.Inst.UI.CheckShow(nameof(SettingsWindow)))
|
||||
{
|
||||
GameSystem.Inst.UI.HideWindow(nameof(SettingsWindow));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameSystem.Inst.UI.ShowWindow<SettingsWindow>(nameof(SettingsWindow));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnAlt(InputAction.CallbackContext context)
|
||||
|
||||
@@ -115,14 +115,14 @@ public class ThirdCharacterController : MonoBehaviour
|
||||
{
|
||||
isCursorLocked = !isCursorLocked;
|
||||
UpdateCursorState();
|
||||
//if (SettingsManager.Inst.isShow())
|
||||
//{
|
||||
// SettingsManager.Inst.CloseSettingWindow();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SettingsManager.Inst.OpenSettingWindow();
|
||||
//}
|
||||
if (GameSystem.Inst.UI.CheckShow(nameof(SettingsWindow)))
|
||||
{
|
||||
GameSystem.Inst.UI.HideWindow(nameof(SettingsWindow));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameSystem.Inst.UI.ShowWindow<SettingsWindow>(nameof(SettingsWindow));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnFire(InputAction.CallbackContext context)
|
||||
|
||||
@@ -8,4 +8,14 @@ public abstract class UIBasePanel : MonoBehaviour
|
||||
public virtual void OnHide() { }
|
||||
|
||||
public virtual void Refresh() { }
|
||||
public virtual void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
OnShow();
|
||||
}
|
||||
public virtual void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
OnHide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public abstract class UIBaseWindow : MonoBehaviour
|
||||
}
|
||||
public virtual void Hide()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
gameObject.SetActive(false);
|
||||
OnHide();
|
||||
}
|
||||
protected virtual void OnShow() { }
|
||||
|
||||
@@ -6,22 +6,22 @@ public class AudioPanel : UIBasePanel, ISettingsPanel
|
||||
{
|
||||
[SerializeField] private Slider masterVolumeSlider;
|
||||
[SerializeField] private AudioMixer audioMixer;
|
||||
|
||||
private void OnEnable()
|
||||
float masterVolume;
|
||||
public override void OnShow()
|
||||
{
|
||||
masterVolumeSlider.value = SettingsManager.Inst.CurrentSettings.masterVolume;
|
||||
masterVolume = masterVolumeSlider.value = SettingsManager.Inst.CurrentSettings.masterVolume;
|
||||
if (audioMixer == null) audioMixer = FindAnyObjectByType<AudioMixer>();
|
||||
}
|
||||
|
||||
public void OnMasterVolumeChanged(float value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = value;
|
||||
masterVolume = value;
|
||||
SetVolume(value);
|
||||
}
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
SetVolume(SettingsManager.Inst.CurrentSettings.masterVolume);
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = masterVolume;
|
||||
}
|
||||
|
||||
private void SetVolume(float volume)
|
||||
@@ -32,6 +32,6 @@ public class AudioPanel : UIBasePanel, ISettingsPanel
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = masterVolume = SettingsManager.Inst.DefSetting.masterVolume;
|
||||
}
|
||||
}
|
||||
@@ -5,29 +5,22 @@ using UnityEngine.UI;
|
||||
public class GeneralPanel : UIBasePanel,ISettingsPanel
|
||||
{
|
||||
[SerializeField] private TMP_InputField serverAddressInput;
|
||||
|
||||
string serverAddress;
|
||||
public override void OnShow()
|
||||
{
|
||||
serverAddressInput.text = SettingsManager.Inst.CurrentSettings.serverAddress;
|
||||
base.Refresh();
|
||||
}
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
}
|
||||
|
||||
public void OnServerAddressChanged(string value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = value;
|
||||
serverAddress = value;
|
||||
}
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
// SettingsManager.Inst.CurrentSettings.serverAddress = value;
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = serverAddress;
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = serverAddress = SettingsManager.Inst.DefSetting.serverAddress;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using YooAsset;
|
||||
|
||||
public class GraphicsManager : Singleton<GraphicsManager>
|
||||
{
|
||||
public GraphicsSetting graphicsSetting;
|
||||
private UniversalRenderPipelineAsset _urpAsset;
|
||||
private VolumeProfile urpVolumeProfile;
|
||||
public GraphicsManager()
|
||||
{
|
||||
_urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
|
||||
if (_urpAsset == null)
|
||||
{
|
||||
Debug.LogError("URP Asset null");
|
||||
}
|
||||
urpVolumeProfile = YooAssets.LoadAssetSync("SampleSceneProfile").AssetObject as VolumeProfile;
|
||||
if (urpVolumeProfile == null)
|
||||
{
|
||||
Debug.LogError("VolumeProfile null");
|
||||
}
|
||||
graphicsSetting = SettingsManager.Inst.CurrentSettings.graphicsSettings;
|
||||
ApplySettings();
|
||||
}
|
||||
public void ApplySettings()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings = graphicsSetting;
|
||||
QualitySettings.vSyncCount = graphicsSetting.vsyncEnabled ? 1 : 0;
|
||||
_urpAsset.shadowDistance = graphicsSetting.shadowDistance;
|
||||
_urpAsset.msaaSampleCount = (int)Mathf.Pow(2, graphicsSetting.qualityLevel);
|
||||
_urpAsset.renderScale = graphicsSetting.renderScale;
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public class GraphicsSetting
|
||||
{
|
||||
public int qualityLevel = 2;
|
||||
public bool vsyncEnabled = true;
|
||||
public float shadowDistance = 50f;
|
||||
public int antiAliasing = 2;
|
||||
public bool bloomEnabled = true;
|
||||
public float renderScale = 1.0f;
|
||||
public bool isCustom = false;
|
||||
|
||||
public GraphicsSetting() { }
|
||||
|
||||
public GraphicsSetting(int quality, bool vsync, float shadows, int aa, bool bloom, float scale)
|
||||
{
|
||||
qualityLevel = quality;
|
||||
vsyncEnabled = vsync;
|
||||
shadowDistance = shadows;
|
||||
antiAliasing = aa;
|
||||
bloomEnabled = bloom;
|
||||
renderScale = scale;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557d237147ace7e4bb16964db0441340
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,160 +15,51 @@ public class GraphicsPanel : UIBasePanel, ISettingsPanel
|
||||
[SerializeField] private Toggle bloomToggle;
|
||||
[SerializeField] private Slider renderScaleSlider;
|
||||
|
||||
[Header("Graphics References")]
|
||||
[SerializeField] private VolumeProfile urpVolumeProfile;
|
||||
|
||||
[Header("Quality Presets")]
|
||||
[SerializeField]
|
||||
private QualityPreset[] qualityPresets = new QualityPreset[4]
|
||||
public override void OnShow()
|
||||
{
|
||||
new QualityPreset("Low", 0, false, 20f, 0, false, 0.8f),
|
||||
new QualityPreset("Medium", 1, false, 40f, 1, true, 1.0f),
|
||||
new QualityPreset("High", 2, true, 60f, 2, true, 1.2f),
|
||||
new QualityPreset("Ultra", 3, true, 100f, 2, true, 1.5f)
|
||||
};
|
||||
|
||||
[System.Serializable]
|
||||
public class QualityPreset
|
||||
{
|
||||
public string name;
|
||||
public int qualityLevel;
|
||||
public bool vsyncEnabled;
|
||||
public float shadowDistance;
|
||||
public int antiAliasing;
|
||||
public bool bloomEnabled;
|
||||
public float renderScale;
|
||||
|
||||
public QualityPreset(string name, int qualityLevel, bool vsyncEnabled, float shadowDistance,
|
||||
int antiAliasing, bool bloomEnabled, float renderScale)
|
||||
{
|
||||
this.name = name;
|
||||
this.qualityLevel = qualityLevel;
|
||||
this.vsyncEnabled = vsyncEnabled;
|
||||
this.shadowDistance = shadowDistance;
|
||||
this.antiAliasing = antiAliasing;
|
||||
this.bloomEnabled = bloomEnabled;
|
||||
this.renderScale = renderScale;
|
||||
}
|
||||
}
|
||||
|
||||
private UniversalRenderPipelineAsset _urpAsset;
|
||||
private Bloom _bloom;
|
||||
private void OnEnable()
|
||||
{
|
||||
StartCoroutine(InitializeDelayed());
|
||||
}
|
||||
|
||||
private IEnumerator InitializeDelayed()
|
||||
{
|
||||
yield return null;
|
||||
|
||||
_urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
|
||||
if (_urpAsset == null)
|
||||
{
|
||||
Debug.LogError("URP Asset null");
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (urpVolumeProfile != null && !urpVolumeProfile.TryGet(out _bloom))
|
||||
{
|
||||
Debug.LogWarning("Volume Profile Bloom null");
|
||||
}
|
||||
|
||||
//InitializeQualityDropdown();
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
qualityDropdown.SetValueWithoutNotify(settings.qualityLevel);
|
||||
vsyncToggle.SetIsOnWithoutNotify(settings.vsyncEnabled);
|
||||
shadowDistanceSlider.SetValueWithoutNotify(settings.shadowDistance);
|
||||
antiAliasingDropdown.SetValueWithoutNotify(settings.antiAliasing);
|
||||
bloomToggle.SetIsOnWithoutNotify(settings.bloomEnabled);
|
||||
renderScaleSlider.SetValueWithoutNotify(settings.renderScale);
|
||||
ApplySettings();
|
||||
qualityDropdown.SetValueWithoutNotify(settings.graphicsSettings.qualityLevel);
|
||||
vsyncToggle.SetIsOnWithoutNotify(settings.graphicsSettings.vsyncEnabled);
|
||||
shadowDistanceSlider.SetValueWithoutNotify(settings.graphicsSettings.shadowDistance);
|
||||
antiAliasingDropdown.SetValueWithoutNotify(settings.graphicsSettings.antiAliasing);
|
||||
bloomToggle.SetIsOnWithoutNotify(settings.graphicsSettings.bloomEnabled);
|
||||
renderScaleSlider.SetValueWithoutNotify(settings.graphicsSettings.renderScale);
|
||||
}
|
||||
|
||||
//private void InitializeQualityDropdown()
|
||||
//{
|
||||
// qualityDropdown.ClearOptions();
|
||||
// foreach (var preset in qualityPresets)
|
||||
// {
|
||||
// qualityDropdown.options.Add(new TMP_Dropdown.OptionData(preset.name));
|
||||
// }
|
||||
//}
|
||||
|
||||
public void OnQualityChanged(int index)
|
||||
{
|
||||
|
||||
SettingsManager.Inst.CurrentSettings.qualityLevel = index;
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
|
||||
if (index >= 0 && index < qualityPresets.Length)
|
||||
{
|
||||
var preset = qualityPresets[index];
|
||||
// Ӧ<><D3A6>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vsyncToggle.SetIsOnWithoutNotify(preset.vsyncEnabled);
|
||||
shadowDistanceSlider.SetValueWithoutNotify(preset.shadowDistance);
|
||||
antiAliasingDropdown.SetValueWithoutNotify(preset.antiAliasing);
|
||||
bloomToggle.SetIsOnWithoutNotify(preset.bloomEnabled);
|
||||
renderScaleSlider.SetValueWithoutNotify(preset.renderScale);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
OnVSyncChanged(settings.vsyncEnabled);
|
||||
OnShadowDistanceChanged(settings.shadowDistance);
|
||||
OnAntiAliasingChanged(settings.antiAliasing);
|
||||
OnBloomChanged(settings.bloomEnabled);
|
||||
OnRenderScaleChanged(settings.renderScale);
|
||||
GameSystem.Inst.Graphics.graphicsSetting.qualityLevel = index;
|
||||
}
|
||||
|
||||
public void OnVSyncChanged(bool value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.vsyncEnabled = value;
|
||||
QualitySettings.vSyncCount = value ? 1 : 0;
|
||||
GameSystem.Inst.Graphics.graphicsSetting.vsyncEnabled = value;
|
||||
}
|
||||
|
||||
public void OnShadowDistanceChanged(float value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.shadowDistance = value;
|
||||
if (_urpAsset != null)
|
||||
_urpAsset.shadowDistance = value;
|
||||
GameSystem.Inst.Graphics.graphicsSetting.shadowDistance = value;
|
||||
}
|
||||
|
||||
public void OnAntiAliasingChanged(int index)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.antiAliasing = index;
|
||||
if (_urpAsset != null)
|
||||
_urpAsset.msaaSampleCount = (int)Mathf.Pow(2, index);
|
||||
GameSystem.Inst.Graphics.graphicsSetting.antiAliasing = index;
|
||||
}
|
||||
|
||||
public void OnBloomChanged(bool value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.bloomEnabled = value;
|
||||
if (_bloom != null)
|
||||
_bloom.active = value;
|
||||
GameSystem.Inst.Graphics.graphicsSetting.bloomEnabled = value;
|
||||
}
|
||||
|
||||
public void OnRenderScaleChanged(float value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.renderScale = value;
|
||||
if (_urpAsset != null)
|
||||
_urpAsset.renderScale = value;
|
||||
GameSystem.Inst.Graphics.graphicsSetting.renderScale = value;
|
||||
}
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
if (_urpAsset == null) return;
|
||||
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
if (settings.qualityLevel != 4)
|
||||
QualitySettings.SetQualityLevel(settings.qualityLevel);
|
||||
QualitySettings.vSyncCount = settings.vsyncEnabled ? 1 : 0;
|
||||
|
||||
_urpAsset.shadowDistance = settings.shadowDistance;
|
||||
_urpAsset.msaaSampleCount = (int)Mathf.Pow(2, settings.antiAliasing);
|
||||
_urpAsset.renderScale = settings.renderScale;
|
||||
|
||||
if (_bloom != null) _bloom.active = settings.bloomEnabled;
|
||||
GameSystem.Inst.Graphics.ApplySettings();
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
|
||||
@@ -7,6 +7,7 @@ public class SettingsManager: Singleton<SettingsManager>
|
||||
{
|
||||
private GameSettings _currentSettings;
|
||||
public GameSettings CurrentSettings => _currentSettings;
|
||||
public GameSettings DefSetting = new GameSettings();
|
||||
private string settingsPath;
|
||||
public SettingsManager()
|
||||
{
|
||||
@@ -33,9 +34,14 @@ public class SettingsManager: Singleton<SettingsManager>
|
||||
string json = JsonUtility.ToJson(_currentSettings, true);
|
||||
File.WriteAllText(settingsPath, json);
|
||||
}
|
||||
#region 图像
|
||||
#endregion 图像
|
||||
|
||||
#region 其他
|
||||
#endregion 其他
|
||||
public void ResetToDefaultSettings()
|
||||
{
|
||||
_currentSettings = new GameSettings();
|
||||
_currentSettings = DefSetting;
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
@@ -43,16 +49,17 @@ public class SettingsManager: Singleton<SettingsManager>
|
||||
[System.Serializable]
|
||||
public class GameSettings
|
||||
{
|
||||
public string serverAddress = "http://127.0.0.1:8080";
|
||||
public string serverAddress ;
|
||||
|
||||
public float masterVolume = 0.75f;
|
||||
|
||||
public int qualityLevel = 2;
|
||||
public bool vsyncEnabled = true;
|
||||
public float shadowDistance = 50f;
|
||||
public int antiAliasing = 2;
|
||||
public bool bloomEnabled = true;
|
||||
public float renderScale = 1.0f;
|
||||
//public int qualityLevel = 2;
|
||||
//public bool vsyncEnabled = true;
|
||||
//public float shadowDistance = 50f;
|
||||
//public int antiAliasing = 2;
|
||||
//public bool bloomEnabled = true;
|
||||
//public float renderScale = 1.0f;
|
||||
public GraphicsSetting graphicsSettings;
|
||||
|
||||
public int resolutionIndex = 0;
|
||||
public bool fullscreen = true;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SettingsWindow : UIBaseWindow
|
||||
displayTab.onClick.AddListener(() => SwitchPanel(displayPanel));
|
||||
|
||||
applyButton.onClick.AddListener(ApplyAllSettings);
|
||||
cancelButton.onClick.AddListener(() => { UIManager.Inst.HideWindow(gameObject.name); });
|
||||
cancelButton.onClick.AddListener(() => { UIManager.Inst.HideWindow(nameof(SettingsWindow)); });
|
||||
defaultsButton.onClick.AddListener(ResetToDefaults);
|
||||
quitButton.onClick.AddListener(() => { Application.Quit(); });
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class SettingsWindow : UIBaseWindow
|
||||
|
||||
SettingsManager.Inst.SaveSettings();
|
||||
|
||||
UIManager.Inst.HideWindow(gameObject.name);
|
||||
UIManager.Inst.HideWindow(nameof(SettingsWindow));
|
||||
}
|
||||
|
||||
public void ResetToDefaults()
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
public class UIManager : SingletonMono<UIManager>
|
||||
public class UIManager : Singleton<UIManager>
|
||||
{
|
||||
Transform uiRoot;
|
||||
Dictionary<string, UIBaseWindow> openedWindows = new Dictionary<string, UIBaseWindow>();
|
||||
@@ -20,9 +20,10 @@ public class UIManager : SingletonMono<UIManager>
|
||||
{
|
||||
YooAssets.LoadAssetAsync<GameObject>(windowName).Completed += handle =>
|
||||
{
|
||||
GameObject go = Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform);
|
||||
GameObject go = GameObject.Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform);
|
||||
var window = go.GetComponent<T>();
|
||||
window.Show();
|
||||
openedWindows[windowName] = window;
|
||||
onShow?.Invoke(window);
|
||||
};
|
||||
}
|
||||
@@ -33,5 +34,20 @@ public class UIManager : SingletonMono<UIManager>
|
||||
{
|
||||
openedWindows[windowName].Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ڣ<EFBFBD>ʹ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
}
|
||||
public bool CheckShow(string windowName)
|
||||
{
|
||||
if (openedWindows.ContainsKey(windowName))
|
||||
{
|
||||
return openedWindows[windowName].gameObject.activeSelf;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,8 @@
|
||||
<Group GroupActiveRule="EnableGroup" GroupName="ShaderVariants" GroupDesc="" AssetTags="">
|
||||
<Collector CollectPath="Assets/Res/Main/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
||||
</Group>
|
||||
<Group GroupActiveRule="EnableGroup" GroupName="Setting" GroupDesc="" AssetTags="">
|
||||
<Collector CollectPath="Assets/Settings/SampleSceneProfile.asset" CollectGUID="a6560a915ef98420e9faacc1c7438823" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||
</Group>
|
||||
</Package>
|
||||
</root>
|
||||
@@ -136,3 +136,16 @@ MonoBehaviour:
|
||||
FilterRuleName: CollectShaderVariants
|
||||
AssetTags:
|
||||
UserData:
|
||||
- GroupName: Setting
|
||||
GroupDesc:
|
||||
AssetTags:
|
||||
ActiveRuleName: EnableGroup
|
||||
Collectors:
|
||||
- CollectPath: Assets/Settings/SampleSceneProfile.asset
|
||||
CollectorGUID: a6560a915ef98420e9faacc1c7438823
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackDirectory
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
UserData:
|
||||
|
||||
@@ -13,45 +13,40 @@ MonoBehaviour:
|
||||
m_Name: Bloom
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
m_AdvancedMode: 0
|
||||
threshold:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
min: 0
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
min: 0
|
||||
scatter:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.7
|
||||
min: 0
|
||||
max: 1
|
||||
clamp:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
min: 0
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
hdr: 0
|
||||
showAlpha: 0
|
||||
showEyeDropper: 1
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
skipIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
min: 0
|
||||
max: 16
|
||||
threshold:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
scatter:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.7
|
||||
clamp:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
downscale:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
maxIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 6
|
||||
dirtTexture:
|
||||
m_OverrideState: 0
|
||||
m_Value: {fileID: 0}
|
||||
dimension: 1
|
||||
dirtIntensity:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
min: 0
|
||||
--- !u!114 &-7011558710299706105
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
@@ -65,26 +60,18 @@ MonoBehaviour:
|
||||
m_Name: Vignette
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
m_AdvancedMode: 0
|
||||
color:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 0, g: 0, b: 0, a: 1}
|
||||
hdr: 0
|
||||
showAlpha: 0
|
||||
showEyeDropper: 1
|
||||
center:
|
||||
m_OverrideState: 0
|
||||
m_Value: {x: 0.5, y: 0.5}
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0.25
|
||||
min: 0
|
||||
max: 1
|
||||
smoothness:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0.4
|
||||
min: 0.01
|
||||
max: 1
|
||||
rounded:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
@@ -98,7 +85,7 @@ MonoBehaviour:
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
|
||||
m_Name: SampleSceneProfile
|
||||
m_Name: Assets/Settings/SampleSceneProfile.asset
|
||||
m_EditorClassIdentifier:
|
||||
components:
|
||||
- {fileID: 849379129802519247}
|
||||
@@ -117,7 +104,30 @@ MonoBehaviour:
|
||||
m_Name: Tonemapping
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
m_AdvancedMode: 0
|
||||
mode:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
neutralHDRRangeReductionMode:
|
||||
m_OverrideState: 0
|
||||
m_Value: 2
|
||||
acesPreset:
|
||||
m_OverrideState: 0
|
||||
m_Value: 3
|
||||
hueShiftAmount:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
detectPaperWhite:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
paperWhite:
|
||||
m_OverrideState: 0
|
||||
m_Value: 300
|
||||
detectBrightnessLimits:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
minNits:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.005
|
||||
maxNits:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1000
|
||||
|
||||
@@ -6,10 +6,10 @@ EditorUserSettings:
|
||||
serializedVersion: 4
|
||||
m_ConfigSettings:
|
||||
RecentlyUsedSceneGuid-0:
|
||||
value: 550256005d025d58090c082113735e4447164c7b797925672b2f1935e1b6326b
|
||||
value: 5300050454035b5f590a0d2341705c441715487929717231297d4a31bab26160
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-1:
|
||||
value: 5300050454035b5f590a0d2341705c441715487929717231297d4a31bab26160
|
||||
value: 550256005d025d58090c082113735e4447164c7b797925672b2f1935e1b6326b
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-2:
|
||||
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
|
||||
|
||||
Reference in New Issue
Block a user