From 643084682a37fb99e21070f06ff54954ec97c731 Mon Sep 17 00:00:00 2001 From: yangbear Date: Fri, 3 Jul 2026 14:30:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20chanraotuibu=E4=BA=A4=E4=BA=92+?= =?UTF-8?q?=E6=91=84=E5=83=8F=E6=9C=BA=E7=9B=B4=E5=88=87+=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E8=B0=83=E6=95=B4+=E9=AB=98=E5=BA=A6=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增ChanraoTuibuHandler: 蓝色矩形闪烁描边, 点击显示模型+激活ping.004 - AudioManager.SwitchToCamera3: 移除淡入淡出改为直接切换 - TouchPositionHandler: point1→激活chanraotuibu(非ping.004) - PingClickHandler高度offset改为0.05f --- Assets/Scripts/Audio/AudioManager.cs | 40 +---------- .../Interaction/ChanraoTuibuHandler.cs | 72 +++++++++++++++++++ .../Interaction/ChanraoTuibuHandler.cs.meta | 11 +++ .../Scripts/Interaction/PingClickHandler.cs | 2 +- .../Interaction/TouchPositionHandler.cs | 9 ++- 5 files changed, 90 insertions(+), 44 deletions(-) create mode 100644 Assets/Scripts/Interaction/ChanraoTuibuHandler.cs create mode 100644 Assets/Scripts/Interaction/ChanraoTuibuHandler.cs.meta diff --git a/Assets/Scripts/Audio/AudioManager.cs b/Assets/Scripts/Audio/AudioManager.cs index 2b49980..b6062f7 100644 --- a/Assets/Scripts/Audio/AudioManager.cs +++ b/Assets/Scripts/Audio/AudioManager.cs @@ -97,48 +97,12 @@ public class AudioManager : MonoBehaviour public void StopVoice() { _voiceSource.Stop(); } - public void SwitchToCamera3Smooth() + public void SwitchToCamera3() { - StartCoroutine(Camera3SwitchRoutine()); - } - - System.Collections.IEnumerator Camera3SwitchRoutine() - { - var black = GameObject.Find("BlackScreenPanel"); - var blackImg = black != null ? black.GetComponent() : null; - float duration = 0.8f; - - // 渐入黑 - if (black != null && blackImg != null) - { - black.SetActive(true); - for (float t = 0f; t < duration; t += Time.deltaTime) - { - blackImg.color = new Color(0, 0, 0, t / duration); - yield return null; - } - blackImg.color = Color.black; - } - - // 切换摄像机 var cam2 = GameObject.Find("camera2"); var cam3 = GameObject.Find("camera3"); if (cam2 != null) { var c = cam2.GetComponent(); if (c != null) c.enabled = false; } if (cam3 != null) { var c = cam3.GetComponent(); if (c != null) c.enabled = true; } - Debug.Log("[AudioManager] camera2→camera3 平滑切换完成"); - - yield return new WaitForSeconds(0.2f); - - // 渐出黑 - if (black != null && blackImg != null) - { - for (float t = 0f; t < duration; t += Time.deltaTime) - { - blackImg.color = new Color(0, 0, 0, 1f - t / duration); - yield return null; - } - blackImg.color = new Color(0, 0, 0, 0); - black.SetActive(false); - } + Debug.Log("[AudioManager] camera2→camera3 直接切换完成"); } } diff --git a/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs new file mode 100644 index 0000000..c165ccc --- /dev/null +++ b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs @@ -0,0 +1,72 @@ +using UnityEngine; + +/// +/// 挂在 chanraotuibu 对象上。蓝色矩形闪烁描边,点击显示模型并激活下个对象(ping.004)。 +/// +public class ChanraoTuibuHandler : MonoBehaviour +{ + public GameObject nextObject; + + private MeshRenderer _meshRenderer; + private LineRenderer _outlineRenderer; + + void OnEnable() + { + _meshRenderer = GetComponent(); + if (_meshRenderer == null) _meshRenderer = GetComponentInChildren(); + if (_meshRenderer != null) _meshRenderer.enabled = false; + CreateBlueOutline(); + StopAllCoroutines(); + StartCoroutine(BlinkOutline()); + } + + void CreateBlueOutline() + { + if (_outlineRenderer != null) return; + var ringGo = new GameObject("BlueRing"); + ringGo.transform.SetParent(transform, false); + _outlineRenderer = ringGo.AddComponent(); + _outlineRenderer.useWorldSpace = true; + _outlineRenderer.loop = true; + _outlineRenderer.startWidth = 0.015f; + _outlineRenderer.endWidth = 0.015f; + _outlineRenderer.material = new Material(Shader.Find("Unlit/Color")); + _outlineRenderer.material.color = new Color(0.2f, 0.5f, 1f); + _outlineRenderer.startColor = new Color(0.2f, 0.5f, 1f); + _outlineRenderer.endColor = new Color(0.2f, 0.5f, 1f); + + // 基于模型 Bounds 画矩形 + Bounds b; + if (_meshRenderer != null) b = _meshRenderer.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); + _outlineRenderer.positionCount = 5; + _outlineRenderer.SetPosition(0, p0); + _outlineRenderer.SetPosition(1, p1); + _outlineRenderer.SetPosition(2, p2); + _outlineRenderer.SetPosition(3, p3); + _outlineRenderer.SetPosition(4, p0); + } + + System.Collections.IEnumerator BlinkOutline() + { + while (true) + { + if (_outlineRenderer != null) _outlineRenderer.enabled = !_outlineRenderer.enabled; + yield return new WaitForSeconds(0.4f); + } + } + + void OnMouseDown() + { + Debug.Log($"[ChanraoTuibu] {name} 被点击"); + StopAllCoroutines(); + if (_meshRenderer != null) _meshRenderer.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/ChanraoTuibuHandler.cs.meta b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs.meta new file mode 100644 index 0000000..949f5a7 --- /dev/null +++ b/Assets/Scripts/Interaction/ChanraoTuibuHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2cf6b55fd9d5146c8a2ba5d06dc8466d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 38e63fc..fc0345e 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -56,7 +56,7 @@ public class PingClickHandler : MonoBehaviour Bounds b; if (_meshRenderer != null) b = _meshRenderer.bounds; else b = new Bounds(transform.position, new Vector3(0.3f, 0.01f, 0.3f)); - float y = _meshRenderer != null ? _meshRenderer.bounds.max.y + 0.02f : transform.position.y + 0.1f; + float y = _meshRenderer != null ? _meshRenderer.bounds.max.y + 0.05f : transform.position.y + 0.1f; 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); diff --git a/Assets/Scripts/Interaction/TouchPositionHandler.cs b/Assets/Scripts/Interaction/TouchPositionHandler.cs index 9b9127c..6e8669f 100644 --- a/Assets/Scripts/Interaction/TouchPositionHandler.cs +++ b/Assets/Scripts/Interaction/TouchPositionHandler.cs @@ -68,22 +68,21 @@ public class TouchPositionHandler : MonoBehaviour if (transform.GetSiblingIndex() == 0) { var amCam = FindObjectOfType(); - if (amCam != null) amCam.SwitchToCamera3Smooth(); + if (amCam != null) amCam.SwitchToCamera3(); } int stepIndex = transform.GetSiblingIndex() + 1; var sm = FindObjectOfType(); if (sm != null) sm.RecordWomanStep(stepIndex); - // point1 点击后激活第一个 ping + // point1 点击后先激活 chanraotuibu if (stepIndex == 1) { var mi = GameObject.Find("manInjury"); if (mi != null) { - var ping4 = mi.transform.Find("ping.004"); - if (ping4 != null) { ping4.gameObject.SetActive(true); Debug.Log("[TouchPosition] ping.004 已激活"); } - FindObjectOfType()?.InitPingSteps(); + var ct = mi.transform.Find("chanraotuibu"); + if (ct != null) { ct.gameObject.SetActive(true); Debug.Log("[TouchPosition] chanraotuibu 已激活"); } } }