2026-03-14 02:30:26 -04:00
|
|
|
using System;
|
2025-01-27 10:29:38 -05:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2025-06-30 09:25:29 -04:00
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Sirenix.OdinInspector;
|
2026-03-14 02:30:26 -04:00
|
|
|
using SLSUtilities.General;
|
2025-01-27 10:29:38 -05:00
|
|
|
using UnityEngine;
|
2025-02-26 22:54:53 -05:00
|
|
|
using UnityEngine.Rendering;
|
2025-06-30 09:25:29 -04:00
|
|
|
using UnityEngine.Rendering.Universal;
|
2025-01-27 10:29:38 -05:00
|
|
|
|
2026-03-14 02:30:26 -04:00
|
|
|
namespace Ichni
|
2025-01-27 10:29:38 -05:00
|
|
|
{
|
2026-03-14 02:30:26 -04:00
|
|
|
public class PostProcessingManager : Singleton<PostProcessingManager>
|
2025-01-27 10:29:38 -05:00
|
|
|
{
|
2026-03-14 02:30:26 -04:00
|
|
|
public static Volume GlobalVolume => instance._globalVolume;
|
2025-06-30 09:25:29 -04:00
|
|
|
|
2026-03-14 02:30:26 -04:00
|
|
|
[ShowInInspector]
|
|
|
|
|
private Volume _globalVolume;
|
|
|
|
|
|
|
|
|
|
protected override void Awake()
|
2025-06-30 09:25:29 -04:00
|
|
|
{
|
2026-03-14 02:30:26 -04:00
|
|
|
base.Awake();
|
|
|
|
|
//FindAndCacheFeatureWithReflection();
|
2025-06-30 09:25:29 -04:00
|
|
|
}
|
2026-03-14 02:30:26 -04:00
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
//FindAndCacheFeatureWithReflection();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-30 09:25:29 -04:00
|
|
|
private void FindAndCacheFeatureWithReflection()
|
|
|
|
|
{
|
|
|
|
|
var pipelineAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
|
|
|
|
if (pipelineAsset == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("当前渲染管线不是 UniversalRenderPipelineAsset。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 使用反射来获取内部的 m_RendererDataList 字段
|
2026-03-14 02:30:26 -04:00
|
|
|
FieldInfo rendererDataListField =
|
|
|
|
|
typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList", BindingFlags.NonPublic | BindingFlags.Instance);
|
2025-06-30 09:25:29 -04:00
|
|
|
if (rendererDataListField == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("在 UniversalRenderPipelineAsset 中无法通过反射找到 'm_RendererDataList' 字段。API可能已在你的URP版本中更改。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rendererDataList = rendererDataListField.GetValue(pipelineAsset) as ScriptableRendererData[];
|
|
|
|
|
if (rendererDataList == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("获取渲染器数据列表失败。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-27 10:29:38 -05:00
|
|
|
}
|
2025-02-26 22:54:53 -05:00
|
|
|
}
|