feat: 音频系统重构 - bg音乐流程修复 + woman语音按点位播放

改动:
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
This commit is contained in:
yangbear
2026-07-01 19:51:41 +08:00
parent 9548492391
commit 8dadc6a58d
14 changed files with 200 additions and 143 deletions

Before

Width:  |  Height:  |  Size: 376 KiB

After

Width:  |  Height:  |  Size: 376 KiB

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 163 KiB

Before

Width:  |  Height:  |  Size: 414 KiB

After

Width:  |  Height:  |  Size: 414 KiB

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 225 KiB

+166 -138
View File
@@ -203,7 +203,7 @@ Camera:
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
@@ -252,13 +252,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2741973}
serializedVersion: 2
m_LocalRotation: {x: 0.079161726, y: 0.65067065, z: -0.06867076, w: 0.7520941}
m_LocalRotation: {x: 0.08211052, y: 0.6831766, z: -0.06511615, w: 0.7226947}
m_LocalPosition: {x: -10.3490305, y: 0.7748528, z: -8.583734}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 11.985, y: 86.891, z: 1.059}
--- !u!1 &4733890
GameObject:
m_ObjectHideFlags: 0
@@ -338,6 +338,122 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4733890}
m_CullTransparentMesh: 1
--- !u!1001 &12263693
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalScale.x
value: 0.011239154
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalScale.y
value: 0.011239154
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalScale.z
value: 0.011239154
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalPosition.x
value: -8.253
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.15394
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalPosition.z
value: -8.29
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_Name
value: Shose
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
insertIndex: -1
addedObject: {fileID: 12263695}
m_SourcePrefab: {fileID: 100100000, guid: ef5fbbeda893849a285d196510e10634, type: 3}
--- !u!1 &12263694 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
m_PrefabInstance: {fileID: 12263693}
m_PrefabAsset: {fileID: 0}
--- !u!114 &12263695
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 12263694}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cbf0e86605f7b485f8ff25c5810d30c0, type: 3}
m_Name:
m_EditorClassIdentifier:
IsDraggable: 1
SnapTarget: {fileID: 0}
OnDragStartEvent:
m_PersistentCalls:
m_Calls: []
OnDragEndEvent:
m_PersistentCalls:
m_Calls: []
OnSnappedEvent:
m_PersistentCalls:
m_Calls: []
--- !u!1001 &19129733
PrefabInstance:
m_ObjectHideFlags: 0
@@ -1739,7 +1855,7 @@ Camera:
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
@@ -3171,6 +3287,9 @@ MonoBehaviour:
_idleDuration: 2
_fadeDuration: 1
_fallHoldDuration: 1.5
_enableOpeningFlow: 1
_basketballClip: {fileID: 8300000, guid: 25ff553be9c84452ab0a39fbfd06be77, type: 3}
_manCallClip: {fileID: 8300000, guid: bc5816d37e79f4461a243f63cd20c925, type: 3}
--- !u!1 &458363765
GameObject:
m_ObjectHideFlags: 0
@@ -3291,6 +3410,37 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 458363765}
m_CullTransparentMesh: 1
--- !u!1 &485512480
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 485512481}
m_Layer: 0
m_Name: ShosePoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &485512481
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 485512480}
serializedVersion: 2
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: -9.694, y: 0.031, z: -7.962}
m_LocalScale: {x: 0.01123915, y: 0.01123915, z: 0.01123915}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &498395086
GameObject:
m_ObjectHideFlags: 0
@@ -3508,8 +3658,8 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 86b2fb2322297431eac4e1a799efb329, type: 3}
m_FontSize: 16
m_Font: {fileID: 12800000, guid: a841e9b00fc7b4a75b9d3d2fd767b62e, type: 3}
m_FontSize: 27
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
@@ -3944,135 +4094,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617526392}
m_CullTransparentMesh: 1
--- !u!1 &672149916
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 672149920}
- component: {fileID: 672149919}
- component: {fileID: 672149918}
- component: {fileID: 672149917}
- component: {fileID: 672149921}
m_Layer: 0
m_Name: Shoe
m_TagString: Shoe
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &672149917
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 672149916}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &672149918
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 672149916}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &672149919
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 672149916}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &672149920
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 672149916}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.7, y: 0.15, z: 5.5}
m_LocalScale: {x: 0.3, y: 0.1, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &672149921
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 672149916}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cbf0e86605f7b485f8ff25c5810d30c0, type: 3}
m_Name:
m_EditorClassIdentifier:
IsDraggable: 1
SnapTarget: {fileID: 0}
OnDragStartEvent:
m_PersistentCalls:
m_Calls: []
OnDragEndEvent:
m_PersistentCalls:
m_Calls: []
OnSnappedEvent:
m_PersistentCalls:
m_Calls: []
--- !u!1 &717077354
GameObject:
m_ObjectHideFlags: 0
@@ -7455,8 +7476,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.1, y: 0.55}
m_AnchorMax: {x: 0.55, y: 0.68}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchoredPosition: {x: 648.76, y: -71}
m_SizeDelta: {x: -12.4866, y: 109.2585}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1285985827
MonoBehaviour:
@@ -9682,6 +9703,12 @@ MonoBehaviour:
_practiceModeDesc: "\u25CF \u6A21\u62DF\u7EC3\u4E60\u6A21\u5F0F\uFF1A\u4E0D\u9650\u65F6\u957F\uFF0C\u53EF\u53CD\u590D\u7EC3\u4E60\u3002\u7CFB\u7EDF\u4E0D\u8BC4\u5206\uFF0C\u5E2E\u52A9\u60A8\u719F\u6089\u5B9E\u9A8C\u6D41\u7A0B\u548C\u64CD\u4F5C\u6B65\u9AA4\u3002"
_examModeDesc: "\u25CF \u8003\u6838\u8BC4\u4F30\u6A21\u5F0F\uFF1A\u9650\u5B9A\u65F6\u95F4\uFF0C\u5B8C\u6210\u540E\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5E76\u63D0\u4F9B\u8BE6\u7EC6\u53CD\u9988\u62A5\u544A\u3002"
_editorPreview: 0
_homeBgClip: {fileID: 8300000, guid: 28a93a41087664f1d9f83a456d17928f, type: 3}
_experimentBgClip: {fileID: 8300000, guid: 4f431e6ae1b9f4b94a61c31fe630647a, type: 3}
_womanClips:
- {fileID: 8300000, guid: 6934b8b2c79df41118a058e984de2a7b, type: 3}
- {fileID: 8300000, guid: 0f561ebe499594da29e31277de2f8a1f, type: 3}
- {fileID: 8300000, guid: 845a704b4410b4393ab9327bfaf9d3ec, type: 3}
--- !u!1 &1654726178
GameObject:
m_ObjectHideFlags: 0
@@ -12082,7 +12109,8 @@ SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 414549209}
- {fileID: 672149920}
- {fileID: 12263693}
- {fileID: 485512481}
- {fileID: 37271319}
- {fileID: 96184422}
- {fileID: 1364120480}
@@ -9,6 +9,7 @@ public class TouchPositionHandler : MonoBehaviour
public Transform targetPosition;
public GameObject womanObject;
public GameObject nextTouchObject;
public AudioClip voiceClip;
private MeshRenderer _meshRenderer;
@@ -37,7 +38,7 @@ public class TouchPositionHandler : MonoBehaviour
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;
+32 -4
View File
@@ -122,7 +122,8 @@ public class PageController : MonoBehaviour
if (_uiManager != null)
_uiManager.enabled = (page == Page.Experiment);
// 背景音乐: 首页播 homeBg, 选固定方式时停, 实验启动时播 experimentBg
if (page == Page.Home) PlayHomeBg();
Debug.Log($"PageController(编辑器预览): 切换到 [{page}]");
}
#endif
@@ -140,7 +141,8 @@ public class PageController : MonoBehaviour
if (_experimentPanel != null) _experimentPanel.SetActive(page == Page.Experiment);
if (_uiManager != null) _uiManager.enabled = (page == Page.Experiment);
// 背景音乐: 首页播 homeBg, 选固定方式时停, 实验启动时播 experimentBg
if (page == Page.Home) PlayHomeBg();
// 背景音乐控制
if (page == Page.Home) PlayHomeBg();
else if (page != Page.Experiment) StopBgMusic();
@@ -261,7 +263,7 @@ public class PageController : MonoBehaviour
Debug.Log($"PageController: GameManager 已设置 Mode=[{gm.CurrentMode}] Fixation=[{gm.CurrentFixationMethod}]");
// 隐藏所有UI面板,准备播放片头动画
HideAllPages();
StopBgMusic(); HideAllPages();
// 找到 OpeningFlowController 播放片头动画
var openingFlow = FindObjectOfType<OpeningFlowController>();
@@ -304,7 +306,6 @@ public class PageController : MonoBehaviour
Debug.Log("PageController: [ActivateExperimentObjects] 显示实验物件");
PlayExperimentBg();
StartCoroutine(PlayWomanAudioSequence());
var allObjects = FindObjectsOfType<GameObject>(true);
foreach (var go in allObjects)
@@ -375,3 +376,30 @@ public class PageController : MonoBehaviour
[SerializeField] private AudioClip[] _womanClips;
private AudioSource _bgAudioSource;
}
private void PlayHomeBg()
{
if (_bgAudioSource == null) _bgAudioSource = gameObject.AddComponent<AudioSource>();
_bgAudioSource.loop = true;
_bgAudioSource.playOnAwake = false;
if (_homeBgClip != null && _bgAudioSource.clip != _homeBgClip)
{
_bgAudioSource.clip = _homeBgClip;
_bgAudioSource.Play();
Debug.Log("PageController: 播放首页背景音乐");
}
}
private void StopBgMusic()
{
if (_bgAudioSource != null && _bgAudioSource.isPlaying) { _bgAudioSource.Stop(); Debug.Log("PageController: 停止背景音乐"); }
}
private void PlayExperimentBg()
{
StopBgMusic();
if (_bgAudioSource == null) _bgAudioSource = gameObject.AddComponent<AudioSource>();
_bgAudioSource.loop = true;
_bgAudioSource.playOnAwake = false;
if (_experimentBgClip != null) { _bgAudioSource.clip = _experimentBgClip; _bgAudioSource.Play(); Debug.Log("PageController: 播放实验背景音乐"); }
}