Files
ichni_Official/Assets/Scripts/Manager/PostProcessingManager.cs

61 lines
2.0 KiB
C#
Raw Normal View History

2025-09-05 10:14:45 -04:00
using System;
2025-06-03 02:42:28 -04:00
using System.Collections;
using System.Collections.Generic;
2025-07-10 08:42:30 -04:00
using System.Linq;
using System.Reflection;
using Sirenix.OdinInspector;
2026-03-14 03:13:10 -04:00
using SLSUtilities.General;
2026-07-19 16:44:58 -04:00
using SLSUtilities.Rendering.PostProcessing;
2025-06-03 02:42:28 -04:00
using UnityEngine;
using UnityEngine.Rendering;
2025-07-10 08:42:30 -04:00
using UnityEngine.Rendering.Universal;
2025-06-03 02:42:28 -04:00
namespace Ichni
{
2026-03-14 03:13:10 -04:00
public class PostProcessingManager : Singleton<PostProcessingManager>
2025-06-03 02:42:28 -04:00
{
2026-07-19 16:44:58 -04:00
/// <summary>
/// 当前已加载的 GameScene 后处理管理器。MenuScene 等未创建该对象的场景会返回 <c>null</c>。
/// </summary>
public static new PostProcessingManager Instance => instance;
2026-07-19 16:44:58 -04:00
2026-03-31 07:51:40 -04:00
public static Volume GlobalVolume => instance.globalVolume;
2026-03-14 03:13:10 -04:00
[ShowInInspector]
2026-03-31 07:51:40 -04:00
public Volume globalVolume;
2025-07-10 08:42:30 -04:00
2026-03-14 03:13:10 -04:00
protected override void Awake()
2025-07-10 08:42:30 -04:00
{
2026-03-14 03:13:10 -04:00
base.Awake();
2026-03-31 07:51:40 -04:00
if (globalVolume != null)
2025-07-10 08:42:30 -04:00
{
2026-03-31 07:51:40 -04:00
// Force instantiate the volume profile on awake so it doesn't happen mid-game
_ = globalVolume.profile;
2025-07-10 08:42:30 -04:00
}
2026-07-19 16:44:58 -04:00
// GameScene 的 Global Volume 创建时,重新应用已加载的玩家设置,覆盖场景切换时的默认值。
SettingsManager.instance?.ApplyPostProcessingSettings();
}
/// <summary>
/// 将全局后处理状态与 Anime Bloom 档位写入 GameScene 的运行时 Profile。
/// Volume.profile 会提供运行时实例,因此不会修改磁盘上的 SampleSceneProfile 资产。
/// </summary>
public void ApplySettings(bool enablePostProcessing, BloomQuality bloomQuality)
{
globalVolume.enabled = enablePostProcessing;
if (!enablePostProcessing || !globalVolume.profile.TryGet(out AnimeBloom animeBloom))
{
return;
}
animeBloom.active = bloomQuality != BloomQuality.Off;
if (animeBloom.active)
{
animeBloom.diffusion.value = bloomQuality == BloomQuality.Performance ? 5 : 6;
2026-07-19 16:44:58 -04:00
}
2025-07-10 08:42:30 -04:00
}
2025-06-03 02:42:28 -04:00
}
2026-07-19 16:44:58 -04:00
}