From 745b11b7f0c01002bffac6c70052195d255f0e16 Mon Sep 17 00:00:00 2001 From: yangbear Date: Fri, 10 Jul 2026 03:50:39 +0800 Subject: [PATCH] Refine Shose undo back to initial voice, fix video looping and hiding, make TipPanel persistent during opening --- .../Animation/OpeningFlowController.cs | 17 +++++++ .../Scripts/Interaction/PingClickHandler.cs | 7 +++ .../Scripts/Interaction/ShoseClickHandler.cs | 44 +++++++++++++++++++ Assets/Scripts/UI/PageController.cs | 22 ---------- Assets/Scripts/UI/VideoController.cs | 4 ++ 5 files changed, 72 insertions(+), 22 deletions(-) diff --git a/Assets/Scripts/Animation/OpeningFlowController.cs b/Assets/Scripts/Animation/OpeningFlowController.cs index 25a4d51..dd35a62 100644 --- a/Assets/Scripts/Animation/OpeningFlowController.cs +++ b/Assets/Scripts/Animation/OpeningFlowController.cs @@ -94,6 +94,15 @@ public class OpeningFlowController : MonoBehaviour { Debug.Log($"[OpeningFlow] PlayOpeningFlow() 被调用, enable={_enableOpeningFlow}"); + // 展示 TipPanel,一直保持到切换 camera2 + var tipPanel = GameObject.Find("TipPanel"); + if (tipPanel == null) + { + var allT = Resources.FindObjectsOfTypeAll(); + foreach(var t in allT) { if (t.name == "TipPanel") { tipPanel = t.gameObject; break; } } + } + if (tipPanel != null) tipPanel.SetActive(true); + // 再次确保开场隐藏鞋子 var shose = GameObject.Find("Shose"); if (shose != null) shose.SetActive(false); @@ -168,6 +177,14 @@ public class OpeningFlowController : MonoBehaviour private void SwitchToCamera2() { + var tipPanel = GameObject.Find("TipPanel"); + if (tipPanel == null) + { + var allT = Resources.FindObjectsOfTypeAll(); + foreach(var t in allT) { if (t.name == "TipPanel") { tipPanel = t.gameObject; break; } } + } + if (tipPanel != null) tipPanel.SetActive(false); + var cam2Go = GameObject.Find("camera2"); if (cam2Go != null) { var c = cam2Go.GetComponent(); if (c != null) { c.enabled = true; Debug.Log("[OpeningFlow] camera2 已启用"); } } else Debug.LogWarning("[OpeningFlow] 未找到 camera2"); diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index e663857..f9107b0 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -131,6 +131,13 @@ public class PingClickHandler : MonoBehaviour if (finishClip != null) am.PlayVoice(finishClip); #endif } + + // 隐藏视频面板 + var videoController = FindObjectOfType(true); + if (videoController != null) + { + videoController.StopVideo(); + } } } } diff --git a/Assets/Scripts/Interaction/ShoseClickHandler.cs b/Assets/Scripts/Interaction/ShoseClickHandler.cs index 89f99f0..24a9fca 100644 --- a/Assets/Scripts/Interaction/ShoseClickHandler.cs +++ b/Assets/Scripts/Interaction/ShoseClickHandler.cs @@ -171,6 +171,50 @@ public class ShoseClickHandler : MonoBehaviour if (nextObject != null) nextObject.SetActive(false); + // --- 恢复相机2、隐藏视频并重新播放语音 --- + var videoController = FindObjectOfType(true); + if (videoController != null) + { + videoController.StopVideo(); + videoController.gameObject.SetActive(false); + } + + var cam2 = GameObject.Find("camera2"); + var cam3 = GameObject.Find("camera3"); + if (cam2 == null) + { + var allT = Resources.FindObjectsOfTypeAll(); + foreach(var t in allT) { if (t.name == "camera2") { cam2 = t.gameObject; break; } } + } + if (cam2 != null) { var c = cam2.GetComponent(); if (c != null) c.enabled = true; } + if (cam3 != null) { var c = cam3.GetComponent(); if (c != null) c.enabled = false; } + + var am = FindObjectOfType(); + if (am != null) + { +#if UNITY_EDITOR + var autoClip = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/Audio/people/周围环境安全,我是救护志愿者,我可以帮助您吗.mp3"); + if (autoClip != null) + { + am.PlayVoice(autoClip); + } +#endif + } + + // 把 woman 重置(取消蹲下) + var woman = GameObject.Find("woman"); + if (woman != null) + { + var anim = woman.GetComponent(); + if (anim != null) + { + anim.SetBool("isCrouch", false); + + } + // 移回原位?如果最初在某个位置,PageController里有记录。这里只要不穿帮即可 + } + // ---------------------------------------- + StopAllCoroutines(); StartCoroutine(BlinkOutline()); } diff --git a/Assets/Scripts/UI/PageController.cs b/Assets/Scripts/UI/PageController.cs index 243fdb1..d51faf0 100644 --- a/Assets/Scripts/UI/PageController.cs +++ b/Assets/Scripts/UI/PageController.cs @@ -451,34 +451,12 @@ public class PageController : MonoBehaviour Debug.Log($"PageController: 开始等待 {waitTime} 秒以切换摄像机并激活鞋子"); - // --- 新增:展示 TipPanel 2秒 --- - var tipPanel = GameObject.Find("TipPanel"); - if (tipPanel == null) - { - var allT = Resources.FindObjectsOfTypeAll(); - foreach(var t in allT) { if (t.name == "TipPanel") { tipPanel = t.gameObject; break; } } - } - if (tipPanel != null) - { - tipPanel.SetActive(true); - // 这里你可以修改 TipPanel 上的文字,如果不修改,它将保持默认内容 - // 等待2秒后再隐藏 - StartCoroutine(HideTipPanelAfterDelay(tipPanel, 2.0f)); - } - // ------------------------------- - yield return new WaitForSeconds(waitTime); // 2. 切换到 camera3 if (am != null) am.SwitchToCamera3(); } - private System.Collections.IEnumerator HideTipPanelAfterDelay(GameObject tipPanel, float delay) - { - yield return new WaitForSeconds(delay); - if (tipPanel != null) tipPanel.SetActive(false); - } - private void HideShose() { var shose = GameObject.Find("Shose"); diff --git a/Assets/Scripts/UI/VideoController.cs b/Assets/Scripts/UI/VideoController.cs index 7e0530d..8a82975 100644 --- a/Assets/Scripts/UI/VideoController.cs +++ b/Assets/Scripts/UI/VideoController.cs @@ -22,8 +22,12 @@ public class VideoController : MonoBehaviour if (_videoPlayer != null) { + _videoPlayer.isLooping = true; _videoPlayer.loopPointReached += OnVideoEnd; } + + // 初始隐藏视频面板 + gameObject.SetActive(false); } /// 播放指定视频文件(StreamingAssets/Videos/ 下)