From 96f6d226580dd78c4e39c91fcaa3f3ecd068e663 Mon Sep 17 00:00:00 2001 From: yangbear Date: Mon, 6 Jul 2026 04:43:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ChanraoTuibu=E8=A1=A5ping=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=E9=87=8D=E4=BA=AE+Shose=20OnEnable=E6=9B=BF=E6=8D=A2S?= =?UTF-8?q?tart+=E6=8F=8F=E8=BE=B9=E5=8A=A0=E7=B2=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interaction/ChanraoTuibuHandler.cs | 22 +++++++------------ .../Scripts/Interaction/ShoseClickHandler.cs | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs index f9257af..be39642 100644 --- a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs +++ b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs @@ -2,18 +2,15 @@ using UnityEngine; public class ChanraoTuibuHandler : MonoBehaviour { - public GameObject nextObject; - private MeshRenderer _modelRenderer, _outlineMesh; + private MeshRenderer _outlineMesh; void OnEnable() { - _modelRenderer = GetComponent(); - if (_modelRenderer == null) _modelRenderer = GetComponentInChildren(); - foreach (var r in GetComponentsInChildren(true)) r.enabled = false; if (GetComponent() == null) gameObject.AddComponent().radius = 0.5f; CreateOutlineMesh(); StopAllCoroutines(); StartCoroutine(BlinkOutline()); + Debug.Log($"[ChanraoTuibu] OnEnable outline={_outlineMesh!=null}"); } void CreateOutlineMesh() @@ -21,11 +18,13 @@ public class ChanraoTuibuHandler : MonoBehaviour if (_outlineMesh != null) return; var mf = GetComponent(); if (mf == null) mf = GetComponentInChildren(); - if (mf == null || mf.sharedMesh == null) return; - var mat = new Material(Shader.Find("Custom/OutlineUnlit")); + if (mf == null || mf.sharedMesh == null) { Debug.LogWarning("[ChanraoTuibu] 无MeshFilter"); return; } + var shader = Shader.Find("Custom/OutlineUnlit"); + if (shader == null) { Debug.LogWarning("[ChanraoTuibu] Shader缺失"); 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); + mat.SetFloat("_OutlineWidth", 0.12f); var go = new GameObject("Outline"); go.transform.SetParent(transform, false); go.AddComponent().sharedMesh = mf.sharedMesh; @@ -37,18 +36,13 @@ public class ChanraoTuibuHandler : 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() { Debug.Log($"[ChanraoTuibu] {name} 被点击"); StopAllCoroutines(); - if (_modelRenderer != null) _modelRenderer.enabled = true; if (_outlineMesh != null) _outlineMesh.enabled = false; // 亮起所有 ping 的边框进入第二轮 diff --git a/Assets/Scripts/Interaction/ShoseClickHandler.cs b/Assets/Scripts/Interaction/ShoseClickHandler.cs index a4f9971..ce26d39 100644 --- a/Assets/Scripts/Interaction/ShoseClickHandler.cs +++ b/Assets/Scripts/Interaction/ShoseClickHandler.cs @@ -8,7 +8,7 @@ public class ShoseClickHandler : MonoBehaviour private Bounds _meshBounds; private bool _clicked; - void Start() + void OnEnable() { // 用模型的精确 Bounds 设 BoxCollider var mf = GetComponent();