From dee680a45838e97504f3f23596de271e568bd549 Mon Sep 17 00:00:00 2001 From: yangbear Date: Fri, 3 Jul 2026 14:44:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20GetComponentsInChildren(true)=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E6=B7=B1=E5=B1=82=E5=AD=90=E6=A8=A1=E5=9E=8B=E9=9A=90?= =?UTF-8?q?=E8=97=8F+SphereCollider=E9=98=B2=E7=82=B9=E5=87=BB=E6=97=A0?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Interaction/ChanraoTuibuHandler.cs | 8 +++++--- Assets/Scripts/Interaction/PingClickHandler.cs | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs index 6d1f22b..8722ed9 100644 --- a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs +++ b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs @@ -14,10 +14,12 @@ public class ChanraoTuibuHandler : MonoBehaviour { _meshRenderer = GetComponent(); if (_meshRenderer == null) _meshRenderer = GetComponentInChildren(); - if (_meshRenderer != null) _meshRenderer.enabled = false; - // 隐藏所有子级 Renderer(确保模型不可见) - var allRends = GetComponentsInChildren(); + // 隐藏所有子级 Renderer(包括 inactive 子级,确保模型不可见) + var allRends = GetComponentsInChildren(true); foreach (var r in allRends) r.enabled = false; + // 确保有大号可点击 collider + var col = GetComponent(); + if (col == null) { var sc = gameObject.AddComponent(); sc.radius = 0.5f; } CreateBlueOutline(); StopAllCoroutines(); StartCoroutine(BlinkOutline()); diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 5a657d4..cffa947 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -29,10 +29,12 @@ public class PingClickHandler : MonoBehaviour { _meshRenderer = GetComponent(); if (_meshRenderer == null) _meshRenderer = GetComponentInChildren(); - if (_meshRenderer != null) _meshRenderer.enabled = false; - // 隐藏所有子级 Renderer(确保模型不可见) - var allRends = GetComponentsInChildren(); + // 隐藏所有子级 Renderer(包括 inactive 子级) + var allRends = GetComponentsInChildren(true); foreach (var r in allRends) r.enabled = false; + // 确保有大号可点击 collider + var col = GetComponent(); + if (col == null) { var sc = gameObject.AddComponent(); sc.radius = 0.5f; } CreateBlueOutline(); _clickedOnce = false; StopAllCoroutines();