From f9807d06d2b0860619ffa632454fac3409776114 Mon Sep 17 00:00:00 2001 From: bottlefish <781230111@qq.com> Date: Thu, 26 Jun 2025 16:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=8A=8A=E6=8B=89=E6=9D=A1?= =?UTF-8?q?=E9=9F=B3=E9=A2=91=E5=81=9C=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/FixSystem/Memory/MemoryProcess.cs | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs b/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs index 98db816bc..b44b1cd2a 100644 --- a/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs +++ b/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs @@ -10,6 +10,7 @@ using AibisDream.Framework; using Cinemachine; using UnityEngine.Rendering; using AibisDream.Kit; +using UnityEngine.EventSystems; public class MemoryProcess : MonoBehaviour { @@ -161,7 +162,7 @@ public class MemoryProcess : MonoBehaviour // 控制音效 - 使用更平滑的速度计算 float currentSpeed = Mathf.Abs(value - lastFrequencyValue) / Time.deltaTime; lastFrequencyValue = value; - UpdateFaderSound(currentSpeed); + // UpdateFaderSound(currentSpeed); } void OnClarityChanged(float value) @@ -179,7 +180,7 @@ public class MemoryProcess : MonoBehaviour // 控制音效 - 使用更平滑的速度计算 float currentSpeed = Mathf.Abs(value - lastClarityValue) / Time.deltaTime; lastClarityValue = value; - UpdateFaderSound(currentSpeed); + // UpdateFaderSound(currentSpeed); } void OnSearchComplete() @@ -252,6 +253,14 @@ public class MemoryProcess : MonoBehaviour frequencySlider.value = 3; lastFrequencyValue = frequencySlider.value; frequencySlider.interactable = true; + // 添加EventTrigger监听 + var trigger = frequencySlider.gameObject.GetComponent() ?? frequencySlider.gameObject.AddComponent(); + var entryDown = new EventTrigger.Entry { eventID = EventTriggerType.PointerDown }; + entryDown.callback.AddListener((data) => OnFaderPointerDown()); + trigger.triggers.Add(entryDown); + var entryUp = new EventTrigger.Entry { eventID = EventTriggerType.PointerUp }; + entryUp.callback.AddListener((data) => OnFaderPointerUp()); + trigger.triggers.Add(entryUp); } if (claritySlider != null) @@ -261,6 +270,14 @@ public class MemoryProcess : MonoBehaviour claritySlider.value = 3; lastClarityValue = claritySlider.value; claritySlider.interactable = true; + // 添加EventTrigger监听 + var trigger = claritySlider.gameObject.GetComponent() ?? claritySlider.gameObject.AddComponent(); + var entryDown = new EventTrigger.Entry { eventID = EventTriggerType.PointerDown }; + entryDown.callback.AddListener((data) => OnFaderPointerDown()); + trigger.triggers.Add(entryDown); + var entryUp = new EventTrigger.Entry { eventID = EventTriggerType.PointerUp }; + entryUp.callback.AddListener((data) => OnFaderPointerUp()); + trigger.triggers.Add(entryUp); } fadeMaterial.SetFloat("_DirectionalDistortionFade", -15f); @@ -404,25 +421,28 @@ public class MemoryProcess : MonoBehaviour return isProcessing; } - private void UpdateFaderSound(float speed) + private void OnFaderPointerDown() { - // 简化速度阈值 - const float minSpeedThreshold = 0.001f; - - if (speed > minSpeedThreshold) // 如果速度大于阈值 - { - if (!isPlayingFaderSound) - { - // 开始播放音效 - AudioManager.Instance.PlaySfx("event:/ActionFB/mem_fader"); - isPlayingFaderSound = true; - } - } - else if (isPlayingFaderSound) - { - // 停止音效 - AudioManager.Instance.StopSfx("event:/ActionFB/mem_fader"); - isPlayingFaderSound = false; - } + // if (!isPlayingFaderSound) + // { + // AudioManager.Instance.PlaySfx("event:/ActionFB/mem_fader"); + // isPlayingFaderSound = true; + // } } + + private void OnFaderPointerUp() + { + // if (isPlayingFaderSound) + // { + // AudioManager.Instance.StopSfx("event:/ActionFB/mem_fader"); + // isPlayingFaderSound = false; + // } + } + + // private void UpdateFaderSound(float speed) + // { + // // 速度归一化,最大速度可根据实际情况调整 + // float normalizedSpeed = Mathf.Clamp01(speed / 10f); + // AudioManager.Instance.SetSfxParam("event:/ActionFB/mem_fader", "mem_fader_speed", normalizedSpeed); + // } } \ No newline at end of file