From 057aa76f2d053969f22aeba41d0e18c8d9b385ee Mon Sep 17 00:00:00 2001 From: yangbear Date: Sun, 12 Jul 2026 03:43:07 +0800 Subject: [PATCH] Fix ping clickable issue on second phase --- .../Scripts/Interaction/PingClickHandler.cs | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 7daa758..65e0190 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -15,9 +15,23 @@ public class PingClickHandler : MonoBehaviour _modelRenderer = GetComponent(); if (_modelRenderer == null) _modelRenderer = GetComponentInChildren(); foreach (var r in GetComponentsInChildren(true)) r.enabled = false; - if (GetComponent() == null) gameObject.AddComponent().radius = 0.5f; + + // 确保碰撞体是打开的 var col = GetComponent(); - if (col != null) col.enabled = true; + if (col == null) + { + var sphere = gameObject.AddComponent(); + sphere.radius = 0.5f; + col = sphere; + } + else if (col is BoxCollider bc) + { + // 如果是之前的 BoxCollider,把它改大一点,确保能点到 + bc.size = new Vector3(Mathf.Max(bc.size.x, 0.5f), Mathf.Max(bc.size.y, 0.5f), Mathf.Max(bc.size.z, 0.5f)); + } + + col.enabled = true; + CreateOutlineMesh(); _modelShown = false; _isBlinking = true; @@ -82,17 +96,19 @@ public class PingClickHandler : MonoBehaviour else { // 如果 nextPing 是 null,说明我是最后一个 ping(也就是 ping.001) - // 此时所有的 ping 都已经显示了模型,进入阶段二:重新点亮所有的 ping 边框 - var allPings = Object.FindObjectsOfType(); - foreach (var p in allPings) + // 此时第一阶段结束,激活 chanraotuibu + var chanraotuibu = GameObject.Find("chanraotuibu"); + if (chanraotuibu == null) { - // 只有未被包扎过的 ping 才能重新亮起边框 - if (p._modelShown) + var mi = GameObject.Find("manInjury"); + if (mi != null) { - p.ReEnableBorder(); + var t = mi.transform.Find("chanraotuibu"); + if (t != null) chanraotuibu = t.gameObject; } } - Debug.Log($"[PingClick] {name} 是最后一个 ping,所有边框已重新激活!"); + if (chanraotuibu != null) chanraotuibu.SetActive(true); + Debug.Log($"[PingClick] {name} 是最后一个 ping 模型,现已激活 chanraotuibu"); } if (nextPing != null) Debug.Log($"[PingClick] {name} 模型显示, 激活 {nextPing.name}"); @@ -122,22 +138,14 @@ public class PingClickHandler : MonoBehaviour if (activePingCount == 0) { - Debug.Log("[PingClick] 所有的 ping 都已经绑成 chanrao 了!现在激活 chanraotuibu。"); - - var chanraotuibu = GameObject.Find("chanraotuibu"); - if (chanraotuibu == null) + Debug.Log("[PingClick] 所有的 ping 都已经绑成 chanrao 了!播放完成语音。"); + var am = FindObjectOfType(); + if (am != null) { - var mi = GameObject.Find("manInjury"); - if (mi != null) - { - var t = mi.transform.Find("chanraotuibu"); - if (t != null) chanraotuibu = t.gameObject; - } - } - - if (chanraotuibu != null) - { - chanraotuibu.SetActive(true); +#if UNITY_EDITOR + var finishClip = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/Audio/people/伤员一切正常,包扎完毕.mp3"); + if (finishClip != null) am.PlayVoice(finishClip); +#endif } // 隐藏视频面板 @@ -157,6 +165,10 @@ public class PingClickHandler : MonoBehaviour if (col != null && !col.enabled) return; _isBlinking = true; + + // 【关键修复点】:确保即使在第二次激活时,碰撞体也被打开,且如果有的话,保证能被点到。 + if (col != null) col.enabled = true; + if (_outlineMesh != null) { _outlineMesh.enabled = true;