diff --git a/Assets/Scripts/Audio/AudioManager.cs b/Assets/Scripts/Audio/AudioManager.cs index a8bef54..2b49980 100644 --- a/Assets/Scripts/Audio/AudioManager.cs +++ b/Assets/Scripts/Audio/AudioManager.cs @@ -94,5 +94,51 @@ public class AudioManager : MonoBehaviour Debug.Log($"[AudioManager] 播放语音: {clip.name}"); } + public void StopVoice() { _voiceSource.Stop(); } + + public void SwitchToCamera3Smooth() + { + StartCoroutine(Camera3SwitchRoutine()); + } + + System.Collections.IEnumerator Camera3SwitchRoutine() + { + var black = GameObject.Find("BlackScreenPanel"); + var blackImg = black != null ? black.GetComponent() : null; + float duration = 0.8f; + + // 渐入黑 + if (black != null && blackImg != null) + { + black.SetActive(true); + for (float t = 0f; t < duration; t += Time.deltaTime) + { + blackImg.color = new Color(0, 0, 0, t / duration); + yield return null; + } + blackImg.color = Color.black; + } + + // 切换摄像机 + var cam2 = GameObject.Find("camera2"); + var cam3 = GameObject.Find("camera3"); + if (cam2 != null) { var c = cam2.GetComponent(); if (c != null) c.enabled = false; } + if (cam3 != null) { var c = cam3.GetComponent(); if (c != null) c.enabled = true; } + Debug.Log("[AudioManager] camera2→camera3 平滑切换完成"); + + yield return new WaitForSeconds(0.2f); + + // 渐出黑 + if (black != null && blackImg != null) + { + for (float t = 0f; t < duration; t += Time.deltaTime) + { + blackImg.color = new Color(0, 0, 0, 1f - t / duration); + yield return null; + } + blackImg.color = new Color(0, 0, 0, 0); + black.SetActive(false); + } + } } diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 4a61bdc..38e63fc 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -56,7 +56,7 @@ public class PingClickHandler : MonoBehaviour Bounds b; if (_meshRenderer != null) b = _meshRenderer.bounds; else b = new Bounds(transform.position, new Vector3(0.3f, 0.01f, 0.3f)); - float y = transform.position.y + 0.1f; + float y = _meshRenderer != null ? _meshRenderer.bounds.max.y + 0.02f : transform.position.y + 0.1f; Vector3 p0 = new Vector3(b.min.x, y, b.min.z); Vector3 p1 = new Vector3(b.min.x, y, b.max.z); Vector3 p2 = new Vector3(b.max.x, y, b.max.z); diff --git a/Assets/Scripts/Interaction/TouchPositionHandler.cs b/Assets/Scripts/Interaction/TouchPositionHandler.cs index 4f0e090..a8a9461 100644 --- a/Assets/Scripts/Interaction/TouchPositionHandler.cs +++ b/Assets/Scripts/Interaction/TouchPositionHandler.cs @@ -66,7 +66,7 @@ public class TouchPositionHandler : MonoBehaviour // 点击point1时平滑切换到camera3 if (transform.GetSiblingIndex() == 0) - StartCoroutine(SwitchToCamera3Smooth()); + var amCam = FindObjectOfType(); if (amCam != null) amCam.SwitchToCamera3Smooth(); int stepIndex = transform.GetSiblingIndex() + 1; var sm = FindObjectOfType(); @@ -110,44 +110,4 @@ public class TouchPositionHandler : MonoBehaviour _sharedVoice.clip = voiceClip; _sharedVoice.Play(); } - System.Collections.IEnumerator SwitchToCamera3Smooth() - { - var black = GameObject.Find("BlackScreenPanel"); - var blackImg = black != null ? black.GetComponent() : null; - float duration = 0.8f; - - // 渐入黑 - if (black != null && blackImg != null) - { - black.SetActive(true); - for (float t = 0f; t < duration; t += Time.deltaTime) - { - blackImg.color = new Color(0, 0, 0, t / duration); - yield return null; - } - blackImg.color = Color.black; - } - - // 切换摄像机 - var cam2 = GameObject.Find("camera2"); - var cam3 = GameObject.Find("camera3"); - if (cam2 != null) { var c = cam2.GetComponent(); if (c != null) c.enabled = false; } - if (cam3 != null) { var c = cam3.GetComponent(); if (c != null) c.enabled = true; } - Debug.Log("[TouchPosition] camera2→camera3 平滑切换完成"); - - yield return new WaitForSeconds(0.2f); - - // 渐出黑 - if (black != null && blackImg != null) - { - for (float t = 0f; t < duration; t += Time.deltaTime) - { - blackImg.color = new Color(0, 0, 0, 1f - t / duration); - yield return null; - } - blackImg.color = new Color(0, 0, 0, 0); - black.SetActive(false); - } - } - }