2026-06-30 02:19:13 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-06-30 03:02:12 +08:00
|
|
|
|
/// 挂在 touchArray 子球体上。球体用双Pass膨胀描边shader(Custom/OutlineUnlit),
|
|
|
|
|
|
/// 闪烁提示用户点击。点击后移动到对应位置并顺序显示下一个。
|
2026-06-30 02:19:13 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class TouchPositionHandler : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public Transform targetPosition;
|
|
|
|
|
|
public GameObject womanObject;
|
2026-06-30 02:24:54 +08:00
|
|
|
|
public GameObject nextTouchObject;
|
2026-07-01 19:51:41 +08:00
|
|
|
|
public AudioClip voiceClip;
|
2026-06-30 02:24:54 +08:00
|
|
|
|
|
2026-06-30 03:02:12 +08:00
|
|
|
|
private MeshRenderer _meshRenderer;
|
2026-06-30 02:32:27 +08:00
|
|
|
|
|
2026-06-30 02:24:54 +08:00
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
2026-06-30 03:02:12 +08:00
|
|
|
|
_meshRenderer = GetComponent<MeshRenderer>();
|
|
|
|
|
|
StartCoroutine(BlinkMesh());
|
2026-06-30 02:32:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-01 21:07:01 +08:00
|
|
|
|
private void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
_meshRenderer = GetComponent<MeshRenderer>();
|
2026-07-03 01:06:54 +08:00
|
|
|
|
if (_meshRenderer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_meshRenderer.enabled = true;
|
|
|
|
|
|
// 只显示描边,填充透明
|
|
|
|
|
|
var mat = _meshRenderer.material;
|
|
|
|
|
|
if (mat != null && mat.HasProperty("_MainColor"))
|
|
|
|
|
|
{
|
|
|
|
|
|
var c = mat.GetColor("_MainColor");
|
|
|
|
|
|
c.a = 0f;
|
|
|
|
|
|
mat.SetColor("_MainColor", c);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-07-01 21:07:01 +08:00
|
|
|
|
StopAllCoroutines();
|
|
|
|
|
|
StartCoroutine(BlinkMesh());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-30 03:02:12 +08:00
|
|
|
|
private System.Collections.IEnumerator BlinkMesh()
|
2026-06-30 02:32:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
2026-07-01 21:07:01 +08:00
|
|
|
|
if (_meshRenderer != null) _meshRenderer.enabled = !_meshRenderer.enabled;
|
2026-06-30 02:32:27 +08:00
|
|
|
|
yield return new WaitForSeconds(0.4f);
|
2026-06-30 02:24:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-30 02:19:13 +08:00
|
|
|
|
|
|
|
|
|
|
private void OnMouseDown()
|
|
|
|
|
|
{
|
2026-06-30 02:24:54 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] {name}: 被点击");
|
|
|
|
|
|
|
2026-06-30 02:19:13 +08:00
|
|
|
|
if (womanObject != null && targetPosition != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
womanObject.transform.position = targetPosition.position;
|
|
|
|
|
|
womanObject.transform.rotation = targetPosition.rotation;
|
2026-06-30 02:48:13 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] woman 移动到 {targetPosition.name}");
|
2026-07-01 21:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (voiceClip != null)
|
|
|
|
|
|
{
|
2026-07-01 21:18:34 +08:00
|
|
|
|
PlaySharedVoice();
|
2026-07-01 21:07:01 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] 播放语音: {voiceClip.name}");
|
|
|
|
|
|
}
|
2026-06-30 02:24:54 +08:00
|
|
|
|
|
2026-07-02 16:07:02 +08:00
|
|
|
|
// 点击point1时平滑切换到camera3
|
|
|
|
|
|
if (transform.GetSiblingIndex() == 0)
|
|
|
|
|
|
StartCoroutine(SwitchToCamera3Smooth());
|
|
|
|
|
|
|
2026-06-30 14:32:30 +08:00
|
|
|
|
int stepIndex = transform.GetSiblingIndex() + 1;
|
|
|
|
|
|
var sm = FindObjectOfType<StepManager>();
|
|
|
|
|
|
if (sm != null) sm.RecordWomanStep(stepIndex);
|
|
|
|
|
|
|
2026-06-30 02:32:27 +08:00
|
|
|
|
StopAllCoroutines();
|
2026-06-30 03:02:12 +08:00
|
|
|
|
if (_meshRenderer != null) _meshRenderer.enabled = false;
|
2026-06-30 02:32:27 +08:00
|
|
|
|
|
2026-06-30 02:24:54 +08:00
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
|
if (nextTouchObject != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
nextTouchObject.SetActive(true);
|
2026-06-30 02:48:13 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] {name} → {nextTouchObject.name} 显示");
|
2026-06-30 02:24:54 +08:00
|
|
|
|
}
|
2026-06-30 02:19:13 +08:00
|
|
|
|
}
|
2026-07-01 21:18:34 +08:00
|
|
|
|
|
|
|
|
|
|
private static AudioSource _sharedVoice;
|
|
|
|
|
|
|
|
|
|
|
|
private void PlaySharedVoice()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (voiceClip == null) return;
|
|
|
|
|
|
if (_sharedVoice == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var go = GameObject.Find("[Managers]");
|
|
|
|
|
|
if (go != null) _sharedVoice = go.AddComponent<AudioSource>();
|
|
|
|
|
|
else { var g = new GameObject("SharedVoice"); _sharedVoice = g.AddComponent<AudioSource>(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
_sharedVoice.Stop();
|
|
|
|
|
|
_sharedVoice.clip = voiceClip;
|
|
|
|
|
|
_sharedVoice.Play();
|
|
|
|
|
|
}
|
2026-07-02 16:07:02 +08:00
|
|
|
|
System.Collections.IEnumerator SwitchToCamera3Smooth()
|
|
|
|
|
|
{
|
|
|
|
|
|
var black = GameObject.Find("BlackScreenPanel");
|
|
|
|
|
|
var blackImg = black != null ? black.GetComponent<UnityEngine.UI.Image>() : 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<Camera>(); if (c != null) c.enabled = false; }
|
|
|
|
|
|
if (cam3 != null) { var c = cam3.GetComponent<Camera>(); if (c != null) c.enabled = true; }
|
|
|
|
|
|
Debug.Log("[TouchPosition] 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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-30 02:19:13 +08:00
|
|
|
|
}
|