This commit is contained in:
SoulliesOfficial
2026-03-14 02:30:26 -04:00
parent cf86f0ee51
commit aee62cd637
2041 changed files with 246771 additions and 129128 deletions

View File

@@ -1,27 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Sirenix.OdinInspector;
using SLSUtilities.General;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace Ichni.Editor
namespace Ichni
{
public class PostProcessingManager : MonoBehaviour
public class PostProcessingManager : Singleton<PostProcessingManager>
{
public Volume globalVolume;
public PostProcessingController nbController;
public PixelateFeature pixelateFeature;
public static Volume GlobalVolume => instance._globalVolume;
void Awake()
[ShowInInspector]
private Volume _globalVolume;
protected override void Awake()
{
FindAndCacheFeatureWithReflection();
SetFeatureActive(false);
SetPixelateStrength(Screen.width, Screen.height);
base.Awake();
//FindAndCacheFeatureWithReflection();
}
private void OnDisable()
{
//FindAndCacheFeatureWithReflection();
}
private void FindAndCacheFeatureWithReflection()
{
var pipelineAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
@@ -32,7 +39,8 @@ namespace Ichni.Editor
}
// 2. 使用反射来获取内部的 m_RendererDataList 字段
FieldInfo rendererDataListField = typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo rendererDataListField =
typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList", BindingFlags.NonPublic | BindingFlags.Instance);
if (rendererDataListField == null)
{
Debug.LogError("在 UniversalRenderPipelineAsset 中无法通过反射找到 'm_RendererDataList' 字段。API可能已在你的URP版本中更改。");
@@ -45,47 +53,6 @@ namespace Ichni.Editor
Debug.LogError("获取渲染器数据列表失败。");
return;
}
// 3. 遍历获取到的列表来查找我们的Feature
foreach (var rendererData in rendererDataList)
{
if (rendererData == null) continue;
var feature = rendererData.rendererFeatures.OfType<PixelateFeature>().FirstOrDefault();
if (feature != null)
{
pixelateFeature = feature;
Debug.Log("成功找到并缓存 pixelateFeature (通过反射)!");
break;
}
}
if (pixelateFeature == null)
{
Debug.LogError("在所有 RendererData 中都未找到 pixelateFeature。");
}
}
public void SetFeatureActive(bool enable)
{
if (pixelateFeature != null)
{
pixelateFeature.SetActive(enable);
}
}
public void SetPixelateStrength(float strengthX, float strengthY)
{
if (pixelateFeature != null)
{
pixelateFeature.settings.pixelateStrengthX = strengthX;
pixelateFeature.settings.pixelateStrengthY = strengthY;
pixelateFeature.pixelatePass.UpdateConfig(strengthX, strengthY);
}
else
{
Debug.LogError("Pixelate feature is not initialized.");
}
}
}
}