Space-Smash-Out/Assets/Scripts/ManagableAudio.cs
Jakob Feldmann 64162cb4a1 feat: whole project restructuring
This can be seen as the initial state of the project after the released demo.

The changes include:
- New ship models
- Singleton manager structure to keep project scaleable in the future
     - Managing players, their settings, character choices, statistics, match setups, controls etc. in a separate decoupled scene
- Main menu with transitions to the arena scene
- Beginnings of a custom audio solution
- Logging with Log4Net

It is really a complete overhaul of the projects structure and management.
2024-04-01 23:06:39 +02:00

47 lines
963 B
C#

using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using log4net;
using UnityEngine;
public class ManagableAudio : MonoBehaviour
{
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
[SerializeField]
private int maxParallel = 1;
public int id = 0;
public string audioTag = "audio";
public AudioSource audioSource;
[HideInInspector]
public List<AudioSource> audioSources;
void Awake()
{
if (gameObject.TryGetComponent(out AudioSource audioS))
{
audioSource = audioS;
}
else
{
Log.Warn("Managable Audio Instance hasn't got an audio source game object"
+ $". Tag:{audioTag} ID:{id}");
return;
}
audioSources.Add(audioSource);
BuildAudioSourceList();
}
private void BuildAudioSourceList()
{
while (audioSources.Count < maxParallel)
{
var newAS = Instantiate(audioSource);
audioSources.Add(newAS);
}
}
}