mirror of
https://github.com/Steffo99/gravity-fusion.git
synced 2024-11-25 09:44:19 +00:00
Add Music Manager
This commit is contained in:
parent
1be6b66541
commit
1f86bb26fd
2 changed files with 50 additions and 0 deletions
39
Assets/Components/MusicManager.cs
Normal file
39
Assets/Components/MusicManager.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class MusicLayer {
|
||||||
|
public AudioSource audioSource;
|
||||||
|
|
||||||
|
public MusicLayer(AudioSource audioSource) {
|
||||||
|
this.audioSource = audioSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Volume {
|
||||||
|
get {
|
||||||
|
return audioSource.volume;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
audioSource.volume = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class MusicManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public List<MusicLayer> layers;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
List<AudioSource> audioSources = new List<AudioSource>();
|
||||||
|
GetComponentsInChildren<AudioSource>(true, audioSources);
|
||||||
|
foreach(AudioSource audioSource in audioSources) {
|
||||||
|
MusicLayer layer = new MusicLayer(audioSource);
|
||||||
|
layer.Volume = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Components/MusicManager.cs.meta
Normal file
11
Assets/Components/MusicManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c5d6ca16f02f68b44bdb6d018c9eb490
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in a new issue