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
@@ -66,7 +66,7 @@ public class TouchPositionHandler : MonoBehaviour
// 点击point1时平滑切换到camera3
if (transform.GetSiblingIndex() == 0)
StartCoroutine(SwitchToCamera3Smooth());
var amCam = FindObjectOfType<AudioManager>(); if (amCam != null) amCam.SwitchToCamera3Smooth();
int stepIndex = transform.GetSiblingIndex() + 1;
var sm = FindObjectOfType<StepManager>();
@@ -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<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("[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);
}
}
}