浏览代码

Implement pause menu music (#463)

/main
GitHub 3 年前
当前提交
0d96fe7f
共有 6 个文件被更改,包括 49 次插入10 次删除
  1. 2
      UOP1_Project/Assets/Prefabs/Gameplay/MusicPlayer.prefab
  2. 15
      UOP1_Project/Assets/Prefabs/UI/GameplayScene/Pause_Screen.prefab
  3. 17
      UOP1_Project/Assets/Scripts/Audio/MusicPlayer.cs
  4. 3
      UOP1_Project/Assets/Scripts/UI/UIPause.cs
  5. 14
      UOP1_Project/Assets/ScriptableObjects/UI/OnPauseOpened.asset
  6. 8
      UOP1_Project/Assets/ScriptableObjects/UI/OnPauseOpened.asset.meta

2
UOP1_Project/Assets/Prefabs/Gameplay/MusicPlayer.prefab


_playMusicOn: {fileID: 11400000, guid: 51854f522e1d88442a90b878b27ea839, type: 2}
_thisSceneSO: {fileID: 0}
_audioConfig: {fileID: 11400000, guid: 7dc92129d2e4ae84dabc197b593ba446, type: 2}
_pauseMusic: {fileID: 11400000, guid: c6f209cf719542c43b6dc260163ff012, type: 2}
_onPauseOpened: {fileID: 11400000, guid: 995da9391d4589044a8819eeb09bab8f, type: 2}

15
UOP1_Project/Assets/Prefabs/UI/GameplayScene/Pause_Screen.prefab


_settingsButton: {fileID: 7616898161678548386}
_backToMenuButton: {fileID: 4846480490438025061}
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
_onPauseOpened: {fileID: 11400000, guid: 995da9391d4589044a8819eeb09bab8f, type: 2}
--- !u!1 &4003648912280857029
GameObject:
m_ObjectHideFlags: 0

m_KeyId: 342818437455872
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 1
m_FormatArguments: []
m_UpdateString:
m_PersistentCalls:

m_KeyId: 344204675899392
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 1
m_FormatArguments: []
m_UpdateString:
m_PersistentCalls:

objectReference: {fileID: 1489275492277599596}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 344bb0b18b7db4b4e8874973eb391ca1, type: 3}
--- !u!224 &3514724217547639128 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 297632141197697313, guid: 344bb0b18b7db4b4e8874973eb391ca1,
type: 3}
m_PrefabInstance: {fileID: 3812202349799155833}
m_PrefabAsset: {fileID: 0}
--- !u!114 &2758040637148793211 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1342405351670587650, guid: 344bb0b18b7db4b4e8874973eb391ca1,

m_Script: {fileID: 11500000, guid: 4100492e3231549df8aa06bff38e1ce9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!224 &3514724217547639128 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 297632141197697313, guid: 344bb0b18b7db4b4e8874973eb391ca1,
type: 3}
m_PrefabInstance: {fileID: 3812202349799155833}
m_PrefabAsset: {fileID: 0}
--- !u!114 &6582248307325847989 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8052293337922855372, guid: 344bb0b18b7db4b4e8874973eb391ca1,

17
UOP1_Project/Assets/Scripts/Audio/MusicPlayer.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class MusicPlayer : MonoBehaviour
{

[SerializeField] private AudioConfigurationSO _audioConfig = default;
[Header("Pause music configuration")]
[SerializeField] private AudioCueSO _pauseMusic = default;
[SerializeField] private BoolEventChannelSO _onPauseOpened = default;
_onPauseOpened.OnEventRaised += PlayPauseMusic;
_onSceneReady.OnEventRaised += PlayMusic;
}

_onPauseOpened.OnEventRaised -= PlayPauseMusic;
}
private void PlayPauseMusic(bool open)
{
if (open)
_playMusicOn.RaisePlayEvent(_pauseMusic, _audioConfig);
else
PlayMusic();
}
}

3
UOP1_Project/Assets/Scripts/UI/UIPause.cs


public UnityAction BackToMainRequested = default;
[SerializeField] private InputReader _inputReader = default;
[SerializeField] private BoolEventChannelSO _onPauseOpened = default;
_onPauseOpened?.OnEventRaised(true);
_resumeButton.SetButton(true);
_inputReader.menuCloseEvent += Resume;
_resumeButton.Clicked += Resume;

private void OnDisable()
{
_onPauseOpened?.OnEventRaised(false);
_inputReader.menuCloseEvent -= Resume;
_resumeButton.Clicked -= Resume;

14
UOP1_Project/Assets/ScriptableObjects/UI/OnPauseOpened.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3177d113f09ae42448cde1e1a5067d4f, type: 3}
m_Name: OnPauseOpened
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/UI/OnPauseOpened.asset.meta


fileFormatVersion: 2
guid: 995da9391d4589044a8819eeb09bab8f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存