update
This commit is contained in:
@@ -19,6 +19,7 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject trackDisplay;
|
||||
public GameObject pathNode;
|
||||
public Material defaultTrackMaterial;
|
||||
public GameObject particleTracker;
|
||||
|
||||
[Title("Trail相关")]
|
||||
public GameObject trail;
|
||||
@@ -36,8 +37,10 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject triggerHint;
|
||||
|
||||
[Title("Effect相关")]
|
||||
public Material defaultParticleMaterial;
|
||||
public GameObject bloomEffect;
|
||||
public GameObject cameraShakeEffect;
|
||||
public GameObject cameraZoomEffect;
|
||||
public GameObject chromaticAberrationEffect;
|
||||
public GameObject vignetteEffect;
|
||||
public GameObject lowPassFilterEffect;
|
||||
|
||||
27
Assets/Scripts/Manager/CustomPrefabsCollection.cs
Normal file
27
Assets/Scripts/Manager/CustomPrefabsCollection.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
[CreateAssetMenu(fileName = "BasePrefabsCollection", menuName = "Ichni/CustomPrefabsCollection", order = 0)]
|
||||
public class CustomPrefabsCollection : SerializedScriptableObject
|
||||
{
|
||||
public string themeBundleName = "theme_bundle_name_here";
|
||||
public Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();
|
||||
|
||||
public GameObject GetPrefab(string prefabName)
|
||||
{
|
||||
if (Prefabs.TryGetValue(prefabName, out GameObject prefab))
|
||||
{
|
||||
return prefab;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Prefab '{prefabName}' not found in {themeBundleName} collection.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/CustomPrefabsCollection.cs.meta
Normal file
11
Assets/Scripts/Manager/CustomPrefabsCollection.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f21a52ae2934677448c0b4addcbcd9da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -34,6 +34,7 @@ namespace Ichni
|
||||
public SongInformation songInformation;
|
||||
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
public Dictionary<string, CustomPrefabsCollection> customPrefabs;
|
||||
|
||||
[Title("UI")]
|
||||
public Canvas judgeHintCanvas;
|
||||
|
||||
@@ -1,12 +1,93 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class PostProcessingManager : MonoBehaviour
|
||||
{
|
||||
public Volume globalVolume;
|
||||
public PixelateFeature pixelateFeature;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
FindAndCacheFeatureWithReflection();
|
||||
SetFeatureActive(false);
|
||||
SetPixelateStrength(Screen.width, Screen.height);
|
||||
}
|
||||
|
||||
private void FindAndCacheFeatureWithReflection()
|
||||
{
|
||||
var pipelineAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
if (pipelineAsset == null)
|
||||
{
|
||||
Debug.LogError("当前渲染管线不是 UniversalRenderPipelineAsset。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 使用反射来获取内部的 m_RendererDataList 字段
|
||||
FieldInfo rendererDataListField =
|
||||
typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (rendererDataListField == null)
|
||||
{
|
||||
Debug.LogError("在 UniversalRenderPipelineAsset 中无法通过反射找到 'm_RendererDataList' 字段。API可能已在你的URP版本中更改。");
|
||||
return;
|
||||
}
|
||||
|
||||
var rendererDataList = rendererDataListField.GetValue(pipelineAsset) as ScriptableRendererData[];
|
||||
if (rendererDataList == null)
|
||||
{
|
||||
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。");
|
||||
}
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void SetFeatureActive(bool enable)
|
||||
{
|
||||
if (pixelateFeature != null)
|
||||
{
|
||||
pixelateFeature.SetActive(enable);
|
||||
}
|
||||
}
|
||||
|
||||
[Button]
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,15 @@ namespace Ichni
|
||||
[Button("TestLoad")]
|
||||
public void TestLoad()
|
||||
{
|
||||
ThemeBundleManager.instance.LoadThemeBundles(new List<string>(){"departure_to_multiverse"});
|
||||
string beatMapFolderPath = "Beatmaps/" + InformationTransistor.instance.chapterName +
|
||||
"/" + InformationTransistor.instance.songName +
|
||||
"/" + InformationTransistor.instance.difficultyName;
|
||||
|
||||
LoadProjectInfo(beatMapFolderPath);
|
||||
LoadSongInfo(beatMapFolderPath);
|
||||
LoadCommandScripts(beatMapFolderPath);
|
||||
|
||||
ThemeBundleManager.instance.LoadThemeBundles(GameManager.instance.projectInformation.selectedThemeBundleList);
|
||||
loadPercent = 0f;
|
||||
|
||||
Observable.EveryUpdate()
|
||||
@@ -40,9 +48,7 @@ namespace Ichni
|
||||
.First()
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
Load(InformationTransistor.instance.chapterName,
|
||||
InformationTransistor.instance.songName,
|
||||
InformationTransistor.instance.difficultyName);
|
||||
LoadBeatMap(beatMapFolderPath);
|
||||
});
|
||||
|
||||
Observable.EveryUpdate()
|
||||
|
||||
Reference in New Issue
Block a user