André McGrail
5 年前
当前提交
3148cc39
共有 20 个文件被更改,包括 2220 次插入 和 1104 次删除
-
2Assets/Data/UniversalRP/PipelineAsset_High.asset
-
2Assets/Data/UniversalRP/PipelineAsset_Low.asset
-
2Assets/Data/UniversalRP/PipelineAsset_Medium.asset
-
41Assets/Resources/AppManager.prefab
-
9Assets/Resources/VolumeHolder.asset
-
39Assets/Scripts/Editor/QualitySettingsExtenstion.cs
-
23Assets/Scripts/GameSystem/AppSettings.cs
-
121Assets/Scripts/GameSystem/DefaultVolume.cs
-
992Assets/scenes/MainMenu.unity
-
2ProjectSettings/QualitySettings.asset
-
8Assets/Objects/Levels/MainMenu.meta
-
8Assets/Objects/UI.meta
-
48Assets/Scripts/GameSystem/VolumeHolder.cs
-
11Assets/Scripts/GameSystem/VolumeHolder.cs.meta
-
1001Assets/Objects/Levels/MainMenu/MainMenuLevel.prefab
-
7Assets/Objects/Levels/MainMenu/MainMenuLevel.prefab.meta
-
1001Assets/Objects/UI/MainMenuUI.prefab
-
7Assets/Objects/UI/MainMenuUI.prefab.meta
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering.Universal; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
public static class DefaultVolume |
|||
public class DefaultVolume : MonoBehaviour |
|||
public static List<VolumeProfile> DefaultVolumes = new List<VolumeProfile>(); |
|||
|
|||
public static void AddVolumes(List<VolumeProfile> volumes) |
|||
public static DefaultVolume instance; |
|||
private Volume volBaseComponent; |
|||
private Volume volQualityComponent; |
|||
private VolumeHolder volHolder; |
|||
|
|||
private void OnEnable() |
|||
DefaultVolumes.AddRange(volumes); |
|||
|
|||
OnValidate(); |
|||
} |
|||
public class DefaultVolumeSwitcher : MonoBehaviour |
|||
{ |
|||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] |
|||
static void LoadVolumeManager() |
|||
private void OnValidate() |
|||
if (FindObjectOfType<VolumeManager>() != null) |
|||
return; |
|||
if (!instance) |
|||
instance = this; |
|||
gameObject.hideFlags = HideFlags.HideAndDontSave; |
|||
if(!volBaseComponent) |
|||
volBaseComponent = gameObject.AddComponent<Volume>(); |
|||
volBaseComponent.priority = -100; |
|||
if(!volQualityComponent) |
|||
volQualityComponent = gameObject.AddComponent<Volume>(); |
|||
volQualityComponent.priority = 100; |
|||
if(!volHolder) |
|||
volHolder = Resources.Load<VolumeHolder>("VolumeHolder"); |
|||
var go = new GameObject { name = "[Volume Manager]" }; |
|||
var volMan = go.AddComponent<VolumeManager>(); |
|||
volMan.Volumes = DefaultVolume.DefaultVolumes; |
|||
volMan.vol = go.AddComponent<Volume>(); |
|||
DontDestroyOnLoad(go); |
|||
UpdateVolume(); |
|||
|
|||
public class VolumeManager : MonoBehaviour |
|||
|
|||
public void UpdateVolume() |
|||
public List<VolumeProfile> Volumes = new List<VolumeProfile>(); |
|||
public Volume vol; |
|||
private void OnEnable() |
|||
if (volHolder) |
|||
{ |
|||
//Setup Base Vol if needed
|
|||
var baseVolIndex = volHolder.GetValue(0); |
|||
if (baseVolIndex >= 0) |
|||
{ |
|||
var vol = volHolder._Volumes[baseVolIndex]; |
|||
volBaseComponent.sharedProfile = vol; |
|||
} |
|||
else |
|||
{ |
|||
volBaseComponent.sharedProfile = null; |
|||
} |
|||
|
|||
//Setup Quality Vol if needed
|
|||
var qualityVolIndex = volHolder.GetValue(QualitySettings.GetQualityLevel() + 1); |
|||
if (qualityVolIndex >= 0) |
|||
{ |
|||
var vol = volHolder._Volumes[qualityVolIndex]; |
|||
volQualityComponent.sharedProfile = vol; |
|||
} |
|||
else |
|||
{ |
|||
volQualityComponent.sharedProfile = null; |
|||
} |
|||
} |
|||
|
|||
if (UniversalRenderPipeline.asset.debugLevel != PipelineDebugLevel.Disabled) |
|||
vol.profile = Volumes[QualitySettings.GetQualityLevel()]; |
|||
string vols = ""; |
|||
foreach (var vol in VolumeManager.instance.stack.components) |
|||
{ |
|||
vols += $"{vol.Key.Name}\n"; |
|||
} |
|||
Debug.Log($"Updated volumes:\n" + |
|||
$" Base Volume : {volBaseComponent.sharedProfile?.name}\n" + |
|||
$" Quality Volume : {volQualityComponent.sharedProfile?.name}\n" + |
|||
$"Total Volume Stack is now:\n" + |
|||
$"{vols}"); |
|||
|
|||
[CreateAssetMenu(fileName = "VolumeHolder", menuName = "Volume Holder", order = 0)] |
|||
public class VolumeHolder : ScriptableObject |
|||
} |
|||
|
|||
#if UNITY_EDITOR
|
|||
[InitializeOnLoad] |
|||
public class StartupVolume |
|||
{ |
|||
private const string goName = "[Volume Manager]"; |
|||
|
|||
static StartupVolume() |
|||
public VolumeProfile[] volumes; |
|||
[SerializeField] |
|||
public Dictionary<int, int> VolumeQualityIndicies = new Dictionary<int, int>(); |
|||
var obj = GameObject.Find(goName)?.GetComponent<DefaultVolume>(); |
|||
if (obj != null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var go = new GameObject { name = goName }; |
|||
var volMan = go.AddComponent<DefaultVolume>(); |
|||
obj = volMan; |
|||
} |
|||
} |
|||
#endif
|
992
Assets/scenes/MainMenu.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 594b57c46a9fe4bdfa534a2d37cbe2f6 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: bbcd327214fc840be8de6b0440106b5b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
|
|||
[CreateAssetMenu(fileName = "VolumeHolder", menuName = "Volume Holder", order = 0)] |
|||
public class VolumeHolder : ScriptableObject |
|||
{ |
|||
[SerializeField] |
|||
public VolumeProfile[] _Volumes; |
|||
[SerializeField] |
|||
public List<int> qualityIndicies = new List<int>(); |
|||
[SerializeField] |
|||
public List<int> qualityVolumeIndicies = new List<int>(); |
|||
|
|||
public bool ContainsKey(int key) |
|||
{ |
|||
return qualityIndicies.Contains(key); |
|||
} |
|||
|
|||
public void Add(int key, int value) |
|||
{ |
|||
qualityIndicies.Add(key); |
|||
qualityVolumeIndicies.Add(value); |
|||
} |
|||
|
|||
public void SetKey(int key, int value) |
|||
{ |
|||
if (qualityIndicies.Contains(key)) |
|||
{ |
|||
qualityVolumeIndicies[qualityIndicies.IndexOf(key)] = value; |
|||
} |
|||
else |
|||
{ |
|||
Add(key, value); |
|||
} |
|||
} |
|||
|
|||
public int GetValue(int key) |
|||
{ |
|||
if (qualityIndicies.Contains(key)) |
|||
{ |
|||
return qualityVolumeIndicies[qualityIndicies.IndexOf(key)]; |
|||
} |
|||
|
|||
throw new Exception(message: $"{qualityIndicies} does not contain key {key}"); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bea894b80a78a4f9a9d5210e78f59e3b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Assets/Objects/Levels/MainMenu/MainMenuLevel.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 705cc40ed7b2348689ba68fd4bc915b3 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Assets/Objects/UI/MainMenuUI.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 56de8e58d1a974ab880e61b104d7ef98 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue