fix: 摄像机切换移到AudioManager+ping高度用bounds.max.y

- 摄像机协程从TouchPositionHandler移到AudioManager上(避免point隐藏后被杀)
- TouchPositionHandler改成调用AudioManager.SwitchToCamera3Smooth
- ping边框Y用_meshRenderer.bounds.max.y+0.02
This commit is contained in:
yangbear
2026-07-03 14:19:37 +08:00
parent dd3eb605b5
commit bf683d77b3
3 changed files with 48 additions and 42 deletions
+46
View File
@@ -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<UnityEngine.UI.Image>() : 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<Camera>(); if (c != null) c.enabled = false; }
if (cam3 != null) { var c = cam3.GetComponent<Camera>(); 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);
}
}
}