add a temporary background music system. To be replaced later.
This commit is contained in:
@@ -13,6 +13,7 @@ MonoBehaviour:
|
||||
m_Name: AddressableAssetGroupSortSettings
|
||||
m_EditorClassIdentifier:
|
||||
sortOrder:
|
||||
- c9bec744898b84f7faa02755bedd48e3
|
||||
- 11c472f60f1ab8142af69f055419e981
|
||||
- 9cbac0921a817ee4ab82e15401d822cd
|
||||
- 711bd3b559b78074294e8454e188fc58
|
||||
|
||||
@@ -15,7 +15,7 @@ MonoBehaviour:
|
||||
m_DefaultGroup: 712e3991f28e549e7a56ee582a977810
|
||||
m_currentHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
Hash: f1752f3dcbab30f470d7c66239dcf3c1
|
||||
m_OptimizeCatalogSize: 0
|
||||
m_BuildRemoteCatalog: 0
|
||||
m_CatalogRequestsTimeout: 0
|
||||
@@ -70,6 +70,7 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: a4c86ee23d4eeb649844f50adf2fadb4, type: 2}
|
||||
- {fileID: 11400000, guid: 797fe3465d47dad4fa5a65c997e26a26, type: 2}
|
||||
- {fileID: 11400000, guid: 5c7374bc56a9447e88024b8d10f93d58, type: 2}
|
||||
- {fileID: 11400000, guid: 90f65e11fe5b44d529bf6d3205841587, type: 2}
|
||||
m_BuildSettings:
|
||||
m_LogResourceManagerExceptions: 1
|
||||
m_BundleBuildPath: Temp/com.unity.addressables/AssetBundles
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
%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: e5d17a21594effb4e9591490b009e7aa, type: 3}
|
||||
m_Name: music_BundledAssetGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 11400000, guid: 90f65e11fe5b44d529bf6d3205841587, type: 2}
|
||||
m_InternalBundleIdMode: 1
|
||||
m_Compression: 1
|
||||
m_IncludeAddressInCatalog: 1
|
||||
m_IncludeGUIDInCatalog: 1
|
||||
m_IncludeLabelsInCatalog: 1
|
||||
m_InternalIdNamingMode: 0
|
||||
m_CacheClearBehavior: 0
|
||||
m_IncludeInBuild: 1
|
||||
m_BundledAssetProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider
|
||||
m_StripDownloadOptions: 0
|
||||
m_ForceUniqueProvider: 0
|
||||
m_UseAssetBundleCache: 1
|
||||
m_UseAssetBundleCrc: 1
|
||||
m_UseAssetBundleCrcForCachedBundles: 1
|
||||
m_UseUWRForLocalBundles: 0
|
||||
m_Timeout: 0
|
||||
m_ChunkedTransfer: 0
|
||||
m_RedirectLimit: -1
|
||||
m_RetryCount: 0
|
||||
m_BuildPath:
|
||||
m_Id: 506465302ec864e8eb6eb8e0d2ee7b2c
|
||||
m_LoadPath:
|
||||
m_Id: 71015b41342024feebebb329061472f1
|
||||
m_BundleMode: 0
|
||||
m_AssetBundleProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
|
||||
m_UseDefaultSchemaSettings: 0
|
||||
m_SelectedPathPairIndex: 0
|
||||
m_BundleNaming: 0
|
||||
m_AssetLoadMode: 0
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6705072e9c59a4c7bb7a39be4baf3ce9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
%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: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
|
||||
m_Name: music_ContentUpdateGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 11400000, guid: 90f65e11fe5b44d529bf6d3205841587, type: 2}
|
||||
m_StaticContent: 0
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93dfc5838da01467e8a0788adb088855
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
%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: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
|
||||
m_Name: music
|
||||
m_EditorClassIdentifier:
|
||||
m_GroupName: music
|
||||
m_GUID: c9bec744898b84f7faa02755bedd48e3
|
||||
m_SerializeEntries:
|
||||
- m_GUID: 42623de26b41d48319c3c98734c657bb
|
||||
m_Address: "music/2014/\u65B0\u624B\u6751/\u5176\u4ED6\u5730\u533A.mp3"
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: e5c504ce180264f2c94e1c18c98495e0
|
||||
m_Address: music/ambiencestereo/daynormal2.wav
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
m_ReadOnly: 0
|
||||
m_Settings: {fileID: 11400000, guid: 070edb522e6e54c14a99055900003890, type: 2}
|
||||
m_SchemaSet:
|
||||
m_Schemas:
|
||||
- {fileID: 11400000, guid: 6705072e9c59a4c7bb7a39be4baf3ce9, type: 2}
|
||||
- {fileID: 11400000, guid: 93dfc5838da01467e8a0788adb088855, type: 2}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90f65e11fe5b44d529bf6d3205841587
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1419f6cd03e824cf3b17ba8ef9ee80ef
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: beeabaddc14c14f07b9793aefc62f9fa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac105eb0ccc374f10b4fea04b01f3d47
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6221f47222ee14f87b8b8ccdfd1ba0c7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42623de26b41d48319c3c98734c657bb
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 8
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df98a3fd090e44f458af27c63a65fd3c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5c504ce180264f2c94e1c18c98495e0
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 8
|
||||
defaultSettings:
|
||||
serializedVersion: 2
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
preloadAudioData: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace BrewMonster.Scripts
|
||||
{
|
||||
public class TemporaryBackgroundMusic : MonoBehaviour
|
||||
{
|
||||
public string backgroundMusicPath;
|
||||
public string ambientSoundPath;
|
||||
|
||||
public AudioSource backgroundMusicSource;
|
||||
public AudioSource ambientSoundSource;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
// get the HostPlayer
|
||||
SetupAudioSources().Forget();
|
||||
}
|
||||
|
||||
private async UniTask SetupAudioSources()
|
||||
{
|
||||
// get the HostPlayer
|
||||
var hostPlayer = CECGameRun.Instance.GetHostPlayer();
|
||||
|
||||
while (hostPlayer == null)
|
||||
{
|
||||
await UniTask.DelayFrame(1);
|
||||
hostPlayer = CECGameRun.Instance.GetHostPlayer();
|
||||
}
|
||||
|
||||
// attach 2 audio source gameobjects to the host player
|
||||
GameObject backgroundMusicObject = new GameObject("BackgroundMusic");
|
||||
backgroundMusicSource = backgroundMusicObject.AddComponent<AudioSource>();
|
||||
backgroundMusicObject.transform.parent = hostPlayer.transform;
|
||||
backgroundMusicObject.transform.localPosition = Vector3.zero;
|
||||
backgroundMusicObject.transform.localRotation = Quaternion.identity;
|
||||
backgroundMusicObject.transform.localScale = Vector3.one;
|
||||
|
||||
GameObject ambientSoundObject = new GameObject("AmbientSound");
|
||||
ambientSoundSource = ambientSoundObject.AddComponent<AudioSource>();
|
||||
ambientSoundObject.transform.parent = hostPlayer.transform;
|
||||
ambientSoundObject.transform.localPosition = Vector3.zero;
|
||||
ambientSoundObject.transform.localRotation = Quaternion.identity;
|
||||
ambientSoundObject.transform.localScale = Vector3.one;
|
||||
|
||||
await PlayBackgroundMusic();
|
||||
}
|
||||
|
||||
private async UniTask PlayBackgroundMusic()
|
||||
{
|
||||
// use AddressableManager to load the background music and ambient sound
|
||||
var backgroundMusicClip = await AddressableManager.Instance.LoadAudioClipAsync(backgroundMusicPath.ToLower());
|
||||
var ambientSoundClip = await AddressableManager.Instance.LoadAudioClipAsync(ambientSoundPath.ToLower());
|
||||
|
||||
// play the background music and ambient sound
|
||||
backgroundMusicSource.clip = backgroundMusicClip;
|
||||
backgroundMusicSource.loop = true;
|
||||
backgroundMusicSource.Play();
|
||||
ambientSoundSource.clip = ambientSoundClip;
|
||||
ambientSoundSource.loop = true;
|
||||
ambientSoundSource.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7177e3c1538c0477bbcbd3beaacea509
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:80a844f1647a00529b585f34c0ce83c7accc751171d522e33b50787654e98940
|
||||
size 5916998
|
||||
oid sha256:1de882c8c5ed30da035a6646b66fb92328fca652f37ee4e0a885cec817a9f741
|
||||
size 5918457
|
||||
|
||||
Reference in New Issue
Block a user