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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user