8dadc6a58d
改动: 1. TouchPositionHandler新增voiceClip字段, 点击时播放对应语音 2. PageController.ShowPage: 首页播放homeBg 3. OnFixationSelected: StopBgMusic()(开场动画开始时停bg) 4. ActivateExperimentObjects: 移除PlayWomanAudioSequence, 保留PlayExperimentBg 5. 新增PlayHomeBg/StopBgMusic/PlayExperimentBg方法 6. 删除_audioManager冗余引用 流程: 首页→homeBg播 → 选固定方式→bg停 → 开场动画→实验bg播 woman语音1→点击point1播, 语音2→point2, 语音3→point3
68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using UnityEngine;
|
||
|
||
/// <summary>
|
||
/// 挂在 touchArray 子球体上。球体用双Pass膨胀描边shader(Custom/OutlineUnlit),
|
||
/// 闪烁提示用户点击。点击后移动到对应位置并顺序显示下一个。
|
||
/// </summary>
|
||
public class TouchPositionHandler : MonoBehaviour
|
||
{
|
||
public Transform targetPosition;
|
||
public GameObject womanObject;
|
||
public GameObject nextTouchObject;
|
||
public AudioClip voiceClip;
|
||
|
||
private MeshRenderer _meshRenderer;
|
||
|
||
private void Start()
|
||
{
|
||
_meshRenderer = GetComponent<MeshRenderer>();
|
||
StartCoroutine(BlinkMesh());
|
||
}
|
||
|
||
private System.Collections.IEnumerator BlinkMesh()
|
||
{
|
||
while (true)
|
||
{
|
||
if (_meshRenderer != null)
|
||
_meshRenderer.enabled = !_meshRenderer.enabled;
|
||
yield return new WaitForSeconds(0.4f);
|
||
}
|
||
}
|
||
|
||
private void OnMouseDown()
|
||
{
|
||
Debug.Log($"[TouchPosition] {name}: 被点击");
|
||
|
||
if (womanObject != null && targetPosition != null)
|
||
{
|
||
womanObject.transform.position = targetPosition.position;
|
||
womanObject.transform.rotation = targetPosition.rotation;
|
||
Debug.Log($"[TouchPosition] woman 移动到 {targetPosition.name}");
|
||
if (voiceClip != null) { var asrc = gameObject.AddComponent<AudioSource>(); asrc.PlayOneShot(voiceClip); Debug.Log("[TouchPosition] 播放语音: " + voiceClip.name); } }
|
||
|
||
// 通知 StepManager 记录步骤
|
||
int stepIndex = transform.GetSiblingIndex() + 1;
|
||
var sm = FindObjectOfType<StepManager>();
|
||
if (sm != null) sm.RecordWomanStep(stepIndex);
|
||
|
||
StopAllCoroutines();
|
||
if (_meshRenderer != null) _meshRenderer.enabled = false;
|
||
|
||
gameObject.SetActive(false);
|
||
if (nextTouchObject != null)
|
||
{
|
||
nextTouchObject.SetActive(true);
|
||
Debug.Log($"[TouchPosition] {name} → {nextTouchObject.name} 显示");
|
||
}
|
||
}
|
||
|
||
|
||
private void OnEnable()
|
||
{
|
||
_meshRenderer = GetComponent<MeshRenderer>();
|
||
if (_meshRenderer != null) _meshRenderer.enabled = true;
|
||
StopAllCoroutines();
|
||
StartCoroutine(BlinkMesh());
|
||
}
|
||
}
|