From 6dbd6917f97b486eb1a57f0de86c7283250cf77b Mon Sep 17 00:00:00 2001 From: bottlefish <781230111@qq.com> Date: Tue, 30 Jun 2026 16:14:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(peipei):=20UF=20=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E6=94=B9=E7=94=B1=E5=90=8E=E5=A4=84=E7=90=86=20Volume=20?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 UF 想象/记忆/Ascii 状态从 unified shader weight 迁移至 Volume weight tween。 Co-authored-by: Cursor --- Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs | 130 ++++++++++++++---- 1 file changed, 100 insertions(+), 30 deletions(-) diff --git a/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs b/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs index 7b176aa4a..8deca61b9 100644 --- a/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs +++ b/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs @@ -25,7 +25,7 @@ public class UFSystem : MonoBehaviour [Header("Global UF Cover")] [SerializeField] private Volume FullAscillVolume; - [Header("Legacy Volumes (unused; kept for scene refs)")] + [Header("Target Post-Processing Volumes")] [SerializeField] private Volume imageAscillVolume; [SerializeField] private Volume imageVolume; [SerializeField] private Volume finalVolume; @@ -44,14 +44,22 @@ public class UFSystem : MonoBehaviour { FixSystemCenter.SystemDic.Register(this); eyeSystem = FindObjectOfType(); - ResetLegacyTargetVolumes(); + ClearUnifiedUfSpriteWeights(); } - private void ResetLegacyTargetVolumes() + public void TweenWeight(Volume postProcessingVolume, float targetWeight, float duration) { - if (imageAscillVolume != null) imageAscillVolume.weight = 0f; - if (imageVolume != null) imageVolume.weight = 0f; - if (finalVolume != null) finalVolume.weight = 0f; + if (postProcessingVolume == null) + { + return; + } + + DOTween.To(() => postProcessingVolume.weight, x => postProcessingVolume.weight = x, targetWeight, duration); + } + + private void ClearUnifiedUfSpriteWeights() + { + eyeSystem?.SetUnifiedUfWeights(0f, 0f, 0f); } [YarnCommand("UF_spriteIn")] @@ -120,54 +128,67 @@ public class UFSystem : MonoBehaviour public IEnumerator UF_ImaginationEffectIn(float duration = 1.5f) { AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - eyeSystem?.TweenUnifiedUfWeights(0f, 1f, 0f, duration); - yield return new WaitForSeconds(duration); + ClearUnifiedUfSpriteWeights(); + TweenWeight(imageVolume, 1f, duration); + yield return new WaitForSeconds(0f); } [YarnCommand("UF_ImaginationEffectOut")] public IEnumerator UF_ImaginationEffectOut(float duration = 1.5f) { - eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration); + TweenWeight(imageVolume, 0f, duration); AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - yield return new WaitForSeconds(duration); + yield return new WaitForSeconds(0f); } [YarnCommand("UF_MemoryEffectIn")] public IEnumerator UF_MemoryEffectIn(float duration = 1.5f) { AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 1f, duration); - yield return new WaitForSeconds(duration); + ClearUnifiedUfSpriteWeights(); + TweenWeight(finalVolume, 1f, duration); + yield return new WaitForSeconds(0f); } [YarnCommand("UF_MemoryEffectOut")] public IEnumerator UF_MemoryEffectOut(float duration = 1.5f) { - eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration); + TweenWeight(finalVolume, 0f, duration); AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - yield return new WaitForSeconds(duration); + yield return new WaitForSeconds(0f); } [YarnCommand("UF_EyeTargetAscillIn")] public IEnumerator UF_EyeTargetAscillIn(float duration = 1.5f) { AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - eyeSystem?.TweenUnifiedUfWeights(1f, 0f, 0f, duration); - yield return new WaitForSeconds(duration); + ClearUnifiedUfSpriteWeights(); + TweenWeight(imageAscillVolume, 1f, duration); + yield return new WaitForSeconds(0f); } [YarnCommand("UF_EyeTargetAscillOut")] public IEnumerator UF_EyeTargetAscillOut(float duration = 1.5f) { - eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration); + TweenWeight(imageAscillVolume, 0f, duration); AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - yield return new WaitForSeconds(duration); + yield return new WaitForSeconds(0f); } [YarnCommand("UF_SetBorkenValue")] public void UF_Borken(int value) { - if (FullAscillVolume != null && FullAscillVolume.profile.TryGet(out ascii)) + if (FullAscillVolume == null) + { + return; + } + + if (!FullAscillVolume.gameObject.activeInHierarchy) + { + FullAscillVolume.gameObject.SetActive(true); + } + + if (FullAscillVolume.profile.TryGet(out ascii)) { ascii.m_Depth.value = value; ascii.m_Ascii.value = Color.red; @@ -189,12 +210,23 @@ public class UFSystem : MonoBehaviour [YarnCommand("UF_fightEffect")] public void UF_fightEffect() { + ClearUnifiedUfSpriteWeights(); scaleTween = DOTween.To(() => 0f, t => { - float dreamWeight = Mathf.Lerp(0f, 1f, t); - float asciiWeight = Mathf.Lerp(0f, 1f, t); - float memoryWeight = Mathf.Lerp(1f, 0f, t); - eyeSystem?.SetUnifiedUfWeights(asciiWeight, dreamWeight, memoryWeight); + if (imageVolume != null) + { + imageVolume.weight = Mathf.Lerp(0f, 1f, t); + } + + if (imageAscillVolume != null) + { + imageAscillVolume.weight = Mathf.Lerp(0f, 1f, t); + } + + if (finalVolume != null) + { + finalVolume.weight = Mathf.Lerp(1f, 0f, t); + } }, 1f, 1f) .SetEase(Ease.InOutSine) .SetLoops(-1, LoopType.Yoyo); @@ -216,10 +248,12 @@ public class UFSystem : MonoBehaviour yield return new WaitForSeconds(0.5f); StartCoroutine(UF_spriteIn(0.5f)); StartCoroutine(UF_ImaginationEffectIn(0.5f)); + eyeSystem.Targets[index].ImageIn(0.5f); yield return new WaitForSeconds(0.5f); StartCoroutine(UF_ImaginationEffectOut(0.5f)); StartCoroutine(UF_MemoryEffectIn(0.5f)); yield return new WaitForSeconds(1f); + eyeSystem.Targets[index].ImageOut(0.5f); StartCoroutine(UF_MemoryEffectOut(0.5f)); index++; if (index >= eyeSystem.Targets.Count - 2) @@ -231,13 +265,27 @@ public class UFSystem : MonoBehaviour public void OpenUFView() { + ClearUnifiedUfSpriteWeights(); + if (FullAscillVolume != null && !FullAscillVolume.gameObject.activeInHierarchy) { FullAscillVolume.gameObject.SetActive(true); } - ResetLegacyTargetVolumes(); - eyeSystem?.SetUnifiedUfWeights(1f, 0f, 0f); + if (imageAscillVolume != null) + { + imageAscillVolume.weight = 1f; + } + + if (imageVolume != null) + { + imageVolume.weight = 0f; + } + + if (finalVolume != null) + { + finalVolume.weight = 0f; + } } public void CloseUFView() @@ -247,8 +295,22 @@ public class UFSystem : MonoBehaviour FullAscillVolume.gameObject.SetActive(false); } - ResetLegacyTargetVolumes(); - eyeSystem?.SetUnifiedUfWeights(0f, 0f, 0f); + if (imageAscillVolume != null) + { + imageAscillVolume.weight = 1f; + } + + if (imageVolume != null) + { + imageVolume.weight = 0f; + } + + if (finalVolume != null) + { + finalVolume.weight = 0f; + } + + ClearUnifiedUfSpriteWeights(); } public void OpenCover() @@ -281,16 +343,24 @@ public class UFSystem : MonoBehaviour } AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); + ClearUnifiedUfSpriteWeights(); + switch (state) { case UFState.UF: - eyeSystem?.TweenUnifiedUfWeights(1f, 0f, 0f, duration); + TweenWeight(imageAscillVolume, 1f, duration); + TweenWeight(imageVolume, 0f, duration); + TweenWeight(finalVolume, 0f, duration); break; case UFState.imagination: - eyeSystem?.TweenUnifiedUfWeights(0f, 1f, 0f, duration); + TweenWeight(imageAscillVolume, 0f, duration); + TweenWeight(imageVolume, 1f, duration); + TweenWeight(finalVolume, 0f, duration); break; case UFState.memory: - eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 1f, duration); + TweenWeight(imageAscillVolume, 0f, duration); + TweenWeight(imageVolume, 0f, duration); + TweenWeight(finalVolume, 1f, duration); break; default: Debug.LogError($"Unhandled state: {state}");