Added Music Manager to play BGM

This commit is contained in:
alantrix0012 2026-01-30 23:24:57 +05:30
parent f5629aa283
commit afb05e4116
9 changed files with 306 additions and 38 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 44a099190c52447f7a3254e3679ecfd8
guid: 25dd9172f3ed8497bb638d649e5309f0
AudioImporter:
externalObjects: {}
serializedVersion: 6

Binary file not shown.

View File

@ -1530,7 +1530,7 @@ RectTransform:
m_Children:
- {fileID: 953941043}
m_Father: {fileID: 0}
m_RootOrder: 17
m_RootOrder: 18
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@ -1566,7 +1566,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 15
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &102349499
GameObject:
@ -1664,7 +1664,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 16
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &114937259
PrefabInstance:
@ -1675,7 +1675,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 1362559069547619857, guid: a3b911323d72e425693591d838971931, type: 3}
propertyPath: m_RootOrder
value: 40
value: 39
objectReference: {fileID: 0}
- target: {fileID: 1362559069547619857, guid: a3b911323d72e425693591d838971931, type: 3}
propertyPath: m_LocalPosition.x
@ -2313,6 +2313,38 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &209700806
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 209700807}
m_Layer: 0
m_Name: Music
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &209700807
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 209700806}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1949154630}
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &218245202
GameObject:
m_ObjectHideFlags: 0
@ -3489,7 +3521,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 51
value: 50
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -3904,7 +3936,7 @@ Transform:
- {fileID: 2046376691}
- {fileID: 1193188584}
m_Father: {fileID: 0}
m_RootOrder: 26
m_RootOrder: 27
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &403482847
GameObject:
@ -4336,7 +4368,7 @@ Transform:
- {fileID: 987201644}
- {fileID: 1251876827}
m_Father: {fileID: 0}
m_RootOrder: 24
m_RootOrder: 25
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &433034051
MonoBehaviour:
@ -5760,7 +5792,7 @@ Transform:
m_Children:
- {fileID: 777143461}
m_Father: {fileID: 0}
m_RootOrder: 25
m_RootOrder: 26
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &591083575
GameObject:
@ -5889,7 +5921,7 @@ Transform:
- {fileID: 1105711058}
- {fileID: 1889666521}
m_Father: {fileID: 0}
m_RootOrder: 21
m_RootOrder: 22
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &612889230 stripped
MonoBehaviour:
@ -5915,7 +5947,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 46
value: 45
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -6081,7 +6113,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 50
value: 49
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -6268,7 +6300,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 45
value: 44
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -6537,7 +6569,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 43
value: 42
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -7355,7 +7387,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 48
value: 47
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -10145,7 +10177,7 @@ Transform:
m_Children:
- {fileID: 1406544797}
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &972828285
GameObject:
@ -10324,7 +10356,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2840576771603088635, guid: da37421badcbd4576a24a3ab7b36ecd9, type: 3}
propertyPath: m_RootOrder
value: 22
value: 23
objectReference: {fileID: 0}
- target: {fileID: 2840576771603088635, guid: da37421badcbd4576a24a3ab7b36ecd9, type: 3}
propertyPath: m_LocalPosition.x
@ -10381,7 +10413,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 44
value: 43
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -11271,7 +11303,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1005647491
GameObject:
@ -13291,7 +13323,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 47
value: 46
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -13349,7 +13381,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 692350080486519524, guid: a8e3aa2657cf941969f210f066c2be8c, type: 3}
propertyPath: m_RootOrder
value: 13
value: 14
objectReference: {fileID: 0}
- target: {fileID: 692350080486519524, guid: a8e3aa2657cf941969f210f066c2be8c, type: 3}
propertyPath: m_LocalPosition.x
@ -13690,7 +13722,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 53
value: 52
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -14239,7 +14271,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1292754754 stripped
MonoBehaviour:
@ -14338,7 +14370,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 38
value: 37
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -14450,7 +14482,7 @@ Transform:
- {fileID: 1107252689}
- {fileID: 247469678}
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1314254205
GameObject:
@ -15139,7 +15171,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 37
value: 36
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -15844,7 +15876,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 40
value: 41
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -16118,7 +16150,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 39
value: 38
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -16771,7 +16803,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5543862162727244199, guid: ac6c492cc5bc64ab58060047f5198136, type: 3}
propertyPath: m_RootOrder
value: 12
value: 13
objectReference: {fileID: 0}
- target: {fileID: 5543862162727244199, guid: ac6c492cc5bc64ab58060047f5198136, type: 3}
propertyPath: m_LocalPosition.x
@ -17819,7 +17851,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1732821612
GameObject:
@ -18990,7 +19022,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 23
m_RootOrder: 24
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1887957727
GameObject:
@ -19041,7 +19073,7 @@ Transform:
- {fileID: 1545603097}
- {fileID: 7686822008443127058}
m_Father: {fileID: 0}
m_RootOrder: 19
m_RootOrder: 20
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1889666520
PrefabInstance:
@ -19557,7 +19589,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 42
value: 40
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -19705,7 +19737,7 @@ Transform:
- {fileID: 75716810}
- {fileID: 1711642273}
m_Father: {fileID: 0}
m_RootOrder: 20
m_RootOrder: 21
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1943884392
GameObject:
@ -19832,6 +19864,158 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1948153070}
m_Mesh: {fileID: 4300004, guid: 25e0b84f10949354b96b98b3742acdde, type: 3}
--- !u!1 &1949154629
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1949154630}
- component: {fileID: 1949154632}
- component: {fileID: 1949154631}
m_Layer: 0
m_Name: MusicManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1949154630
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1949154629}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 209700807}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &1949154631
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1949154629}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: -176124199341068130, guid: 12870a2f915674f679b5025697171155, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &1949154632
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1949154629}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6f598c418041d4a9e89aa7a25efc1185, type: 3}
m_Name:
m_EditorClassIdentifier:
audioSource: {fileID: 1949154631}
musicDatas:
- musicType: 0
priority: 1
musicClip: {fileID: 8300000, guid: 2aaeabf9c4da5458d99bb9210024afaf, type: 3}
- musicType: 1
priority: 1
musicClip: {fileID: 8300000, guid: 3fef0c7922e3840f79c05fb9a520dde3, type: 3}
- musicType: 2
priority: 1
musicClip: {fileID: 8300000, guid: 25dd9172f3ed8497bb638d649e5309f0, type: 3}
--- !u!1 &1954289399
GameObject:
m_ObjectHideFlags: 0
@ -20436,7 +20620,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_RootOrder
value: 52
value: 51
objectReference: {fileID: 0}
- target: {fileID: 8564956122812130069, guid: 515d8b1f77d464a81b58cf47b8f04768, type: 3}
propertyPath: m_LocalPosition.x
@ -21038,7 +21222,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 18
m_RootOrder: 19
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2076908155
PrefabInstance:
@ -22360,7 +22544,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1003433482227882326, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
propertyPath: m_RootOrder
value: 14
value: 15
objectReference: {fileID: 0}
- target: {fileID: 1003433482227882326, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
propertyPath: m_LocalPosition.x
@ -24909,7 +25093,7 @@ RectTransform:
- {fileID: 5608193482973815123}
- {fileID: 5608193482197189504}
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e82d850a90884a54a07beff74d9a324
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum MusicType
{
HomeMusic,
GameMusic,
GameOverMusic
}
[System.Serializable]
public class MusicData
{
public MusicType musicType;
public int priority;
public AudioClip musicClip;
}
public class MusicManager : MonoBehaviour, IBootLoader, IBase, IDataLoader
{
[SerializeField] AudioSource audioSource;
[SerializeField] private MusicData[] musicDatas;
public bool IsGamemusicOn
{
get;
private set;
}
private Dictionary<MusicType, MusicData> musicDataDict = new Dictionary<MusicType, MusicData>();
public void Initialize()
{
InterfaceManager.Instance?.RegisterInterface<MusicManager>(this);
}
public void InitializeData()
{
audioSource.priority = 0;
for (int idx = 0; idx < musicDatas.Length; idx++)
{
if (musicDataDict.ContainsKey(musicDatas[idx].musicType))
musicDataDict[musicDatas[idx].musicType] = musicDatas[idx];
else
musicDataDict.Add(musicDatas[idx].musicType, musicDatas[idx]);
}
}
public void SetGamemusic(bool state)
{
IsGamemusicOn = state;
}
public void PlayMusicClip(MusicType musicType)
{
if (!enabled) return;
MusicData musicData = musicDataDict[musicType];
audioSource.priority = musicData.priority;
audioSource.clip = musicData.musicClip;
audioSource.Play();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6f598c418041d4a9e89aa7a25efc1185
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: