From e9e7db0669a073a154971502a56bfd5cc38d36fe Mon Sep 17 00:00:00 2001 From: yangbear Date: Mon, 6 Jul 2026 04:49:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B5=81=E7=A8=8B=E9=87=8D=E6=8E=92?= =?UTF-8?q?=E2=80=94Shoe=E2=86=92chanraotuibu=E2=86=92ping004=E2=86=92?= =?UTF-8?q?=E9=80=90=E7=82=B9=E6=A8=A1=E5=9E=8B=E2=86=92chanrao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interaction/ChanraoTuibuHandler.cs | 23 +++------ .../Scripts/Interaction/PingClickHandler.cs | 50 +++++++------------ 2 files changed, 26 insertions(+), 47 deletions(-) diff --git a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs index be39642..c601340 100644 --- a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs +++ b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs @@ -2,6 +2,7 @@ using UnityEngine; public class ChanraoTuibuHandler : MonoBehaviour { + public GameObject nextObject; private MeshRenderer _outlineMesh; void OnEnable() @@ -44,21 +45,11 @@ public class ChanraoTuibuHandler : MonoBehaviour Debug.Log($"[ChanraoTuibu] {name} 被点击"); StopAllCoroutines(); if (_outlineMesh != null) _outlineMesh.enabled = false; - - // 亮起所有 ping 的边框进入第二轮 - var mi = GameObject.Find("manInjury"); - if (mi != null) - { - for (int i = 4; i >= 1; i--) - { - var pt = mi.transform.Find("ping." + i.ToString("D3")); - if (pt != null && pt.gameObject.activeSelf) - { - var h = pt.gameObject.GetComponent(); - if (h != null) h.ReEnableBorder(); - } - } - Debug.Log("[ChanraoTuibu] ping边框第二轮已亮起"); - } + // 显示模型 + var mr = GetComponent(); + if (mr != null) mr.enabled = true; + foreach (var r in GetComponentsInChildren(true)) r.enabled = true; + // 激活下一个(ping.004) + if (nextObject != null) { nextObject.SetActive(true); Debug.Log($"[ChanraoTuibu] → {nextObject.name}"); } } } diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 20933ff..a889f38 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -4,20 +4,17 @@ public class PingClickHandler : MonoBehaviour { public GameObject chanraoObject, nextPing; public int pingIndex; - private MeshRenderer _modelRenderer, _outlineMesh; - private bool _clickedOnce; - private static int _firstClickCount; + private bool _modelShown; void OnEnable() { _modelRenderer = GetComponent(); if (_modelRenderer == null) _modelRenderer = GetComponentInChildren(); - if (_modelRenderer != null) _modelRenderer.enabled = false; foreach (var r in GetComponentsInChildren(true)) r.enabled = false; if (GetComponent() == null) gameObject.AddComponent().radius = 0.5f; CreateOutlineMesh(); - _clickedOnce = false; + _modelShown = false; StopAllCoroutines(); StartCoroutine(BlinkOutline()); } @@ -28,7 +25,9 @@ public class PingClickHandler : MonoBehaviour var mf = GetComponent(); if (mf == null) mf = GetComponentInChildren(); if (mf == null || mf.sharedMesh == null) return; - var mat = new Material(Shader.Find("Custom/OutlineUnlit")); + var shader = Shader.Find("Custom/OutlineUnlit"); + if (shader == null) return; + var mat = new Material(shader); mat.SetColor("_OutlineColor", new Color(0.2f, 0.5f, 1f, 1f)); mat.SetColor("_MainColor", new Color(0, 0, 0, 0)); mat.SetFloat("_OutlineWidth", 0.1f); @@ -43,52 +42,41 @@ public class PingClickHandler : MonoBehaviour { if (_outlineMesh != null) _outlineMesh.enabled = true; yield return new WaitForSeconds(0.4f); - while (true) - { - if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled; - yield return new WaitForSeconds(0.4f); - } + while (true) { if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled; yield return new WaitForSeconds(0.4f); } } void OnMouseDown() { + // touchArray 优先 foreach (var c in Object.FindObjectsOfType()) { if (!c.enabled) continue; foreach (var h in Physics.RaycastAll(c.ScreenPointToRay(Input.mousePosition))) - if (h.collider != null && h.collider.transform.parent != null && h.collider.transform.parent.name == "touchArray") return; + if (h.collider?.transform.parent?.name == "touchArray") return; } - if (_firstClickCount < 4) + if (!_modelShown) { - if (_clickedOnce) return; - _clickedOnce = true; _firstClickCount++; + // 首次点击: 显示模型,隐藏边框,激活下一个 ping + _modelShown = true; StopAllCoroutines(); if (_modelRenderer != null) _modelRenderer.enabled = true; + foreach (var r in GetComponentsInChildren(true)) r.enabled = true; if (_outlineMesh != null) _outlineMesh.enabled = false; if (nextPing != null) nextPing.SetActive(true); - Debug.Log($"[PingClick] {name} 第1击 ({_firstClickCount}/4)"); - if (_firstClickCount >= 4) - { - var mi = GameObject.Find("manInjury"); - if (mi != null) { var ct = mi.transform.Find("chanraotuibu"); if (ct != null) { ct.gameObject.SetActive(true); Debug.Log("[PingClick] chanraotuibu 激活"); } } - } - var sm = FindObjectOfType(); if (sm != null) sm.RecordPingStep(pingIndex, false); + Debug.Log($"[PingClick] {name} 模型显示, 激活 {nextPing?.name}"); + var sm = FindObjectOfType(); + if (sm != null) sm.RecordPingStep(pingIndex, false); } else { - if (!_clickedOnce) return; - if (chanraoObject != null) chanraoObject.SetActive(true); - StopAllCoroutines(); - if (_modelRenderer != null) _modelRenderer.enabled = false; - if (_outlineMesh != null) _outlineMesh.enabled = false; + // 模型已显示: 点击显示 chanrao + if (chanraoObject != null) { chanraoObject.SetActive(true); Debug.Log($"[PingClick] {name} → {chanraoObject.name}"); } gameObject.SetActive(false); - Debug.Log($"[PingClick] {name} 第2击"); - var sm = FindObjectOfType(); if (sm != null) sm.RecordPingStep(pingIndex, true); + var sm = FindObjectOfType(); + if (sm != null) sm.RecordPingStep(pingIndex, true); } } public void ReEnableBorder() { if (_outlineMesh != null) { _outlineMesh.enabled = true; StopAllCoroutines(); StartCoroutine(BlinkOutline()); } } - public void UndoSecondClick() { if (!_clickedOnce) return; _clickedOnce = false; _firstClickCount--; gameObject.SetActive(true); if (_modelRenderer != null) _modelRenderer.enabled = false; StopAllCoroutines(); StartCoroutine(BlinkOutline()); } - public void UndoShow() { gameObject.SetActive(false); } }