diff --git a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs index c165ccc..bf665fd 100644 --- a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs +++ b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs @@ -15,6 +15,9 @@ public class ChanraoTuibuHandler : MonoBehaviour _meshRenderer = GetComponent(); if (_meshRenderer == null) _meshRenderer = GetComponentInChildren(); if (_meshRenderer != null) _meshRenderer.enabled = false; + // 隐藏所有子级 Renderer(确保模型不可见) + var allRends = GetComponentsInChildren(); + foreach (var r in allRends) r.enabled = false; CreateBlueOutline(); StopAllCoroutines(); StartCoroutine(BlinkOutline()); @@ -36,14 +39,20 @@ public class ChanraoTuibuHandler : MonoBehaviour _outlineRenderer.endColor = new Color(0.2f, 0.5f, 1f); // 基于模型 Bounds 画矩形 + Renderer rend = _meshRenderer; + if (rend == null) rend = GetComponentInChildren(); Bounds b; - if (_meshRenderer != null) b = _meshRenderer.bounds; + if (rend != null) b = rend.bounds; else b = new Bounds(transform.position, new Vector3(0.3f, 0.01f, 0.3f)); - float y = b.max.y + 0.05f; - Vector3 p0 = new Vector3(b.min.x, y, b.min.z); - Vector3 p1 = new Vector3(b.min.x, y, b.max.z); - Vector3 p2 = new Vector3(b.max.x, y, b.max.z); - Vector3 p3 = new Vector3(b.max.x, y, b.min.z); + // 扩展 20% 让边框包住模型 + Vector3 ctr = b.center; + Vector3 ext = b.extents * 1.2f; + float y = b.max.y + 0.08f; + Vector3 p0 = new Vector3(ctr.x - ext.x, y, ctr.z - ext.z); + Vector3 p1 = new Vector3(ctr.x - ext.x, y, ctr.z + ext.z); + Vector3 p2 = new Vector3(ctr.x + ext.x, y, ctr.z + ext.z); + Vector3 p3 = new Vector3(ctr.x + ext.x, y, ctr.z - ext.z); + Debug.Log($"[{f}] 边框 bounds: center={ctr} extents={ext} y={y}"); _outlineRenderer.positionCount = 5; _outlineRenderer.SetPosition(0, p0); _outlineRenderer.SetPosition(1, p1); @@ -66,6 +75,8 @@ public class ChanraoTuibuHandler : MonoBehaviour Debug.Log($"[ChanraoTuibu] {name} 被点击"); StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = true; + var allRends2 = GetComponentsInChildren(); + foreach (var r in allRends2) r.enabled = true; if (_outlineRenderer != null) _outlineRenderer.enabled = true; 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 fc0345e..5a657d4 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -30,6 +30,9 @@ public class PingClickHandler : MonoBehaviour _meshRenderer = GetComponent(); if (_meshRenderer == null) _meshRenderer = GetComponentInChildren(); if (_meshRenderer != null) _meshRenderer.enabled = false; + // 隐藏所有子级 Renderer(确保模型不可见) + var allRends = GetComponentsInChildren(); + foreach (var r in allRends) r.enabled = false; CreateBlueOutline(); _clickedOnce = false; StopAllCoroutines(); @@ -105,6 +108,8 @@ public class PingClickHandler : MonoBehaviour _firstClickCount++; StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = true; + var allRends2 = GetComponentsInChildren(); + foreach (var r in allRends2) r.enabled = true; if (_outlineRenderer != null) _outlineRenderer.enabled = true; if (nextPing != null) { nextPing.SetActive(true); Debug.Log($"[PingClick] {name} → {nextPing.name} 激活"); } Debug.Log($"[PingClick] {name} 第1击 (model显示, {_firstClickCount}/4)"); @@ -118,6 +123,9 @@ public class PingClickHandler : MonoBehaviour if (chanraoObject != null) { chanraoObject.SetActive(true); Debug.Log($"[PingClick] {chanraoObject.name} 已显示"); } StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = false; + // 隐藏所有子级 Renderer(确保模型不可见) + var allRends = GetComponentsInChildren(); + foreach (var r in allRends) r.enabled = false; if (_outlineRenderer != null) _outlineRenderer.enabled = false; gameObject.SetActive(false); Debug.Log($"[PingClick] {name} 第2击 (chanrao显示)"); @@ -133,6 +141,9 @@ public class PingClickHandler : MonoBehaviour _firstClickCount--; gameObject.SetActive(true); if (_meshRenderer != null) _meshRenderer.enabled = false; + // 隐藏所有子级 Renderer(确保模型不可见) + var allRends = GetComponentsInChildren(); + foreach (var r in allRends) r.enabled = false; StopAllCoroutines(); StartCoroutine(BlinkOutline()); } diff --git a/Assets/Video 1.meta b/Assets/Video 1.meta new file mode 100644 index 0000000..5a2c039 --- /dev/null +++ b/Assets/Video 1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 44e25f60f2f814cef90b59c66c377f07 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: