1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-25 01:34:18 +00:00

Add Music Manager

This commit is contained in:
Steffo 2019-10-05 15:59:17 +02:00
parent 1be6b66541
commit 1f86bb26fd
2 changed files with 50 additions and 0 deletions

View 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;
}
}
}

View file

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