Audio Management + Animations

This commit is contained in:
kingjuulian06
2023-12-29 02:26:42 +01:00
parent 403062d355
commit 3e751b3ad7
457 changed files with 43748 additions and 1313 deletions
+78
View File
@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
using FMOD.Studio;
public class AudioManager : MonoBehaviour
{
private List<EventInstance> eventInstances;
private EventInstance musicEventInstance;
public static AudioManager instance { get; private set; }
private void Awake()
{
if (instance != null)
{
Debug.LogError("Found more than one Audio Manager in the scene");
}
instance = this;
eventInstances = new List<EventInstance>();
}
private void Start()
{
InitializeMusic(FMODEvents.instance.music);
}
private void InitializeMusic(EventReference musicEventReference)
{
musicEventInstance = CreateEventInstance(musicEventReference);
musicEventInstance.start();
}
public void PlayOneShot(EventReference sound, Vector3 worldPos)
{
RuntimeManager.PlayOneShot(sound, worldPos);
}
public void PauseMusic()
{
musicEventInstance.setPaused(true);
}
public void PlayMusic()
{
musicEventInstance.setPaused(false);
}
public void StopMusic()
{
musicEventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
}
public EventInstance CreateEventInstance(EventReference eventReference)
{
EventInstance eventInstance = RuntimeManager.CreateInstance(eventReference);
eventInstances.Add(eventInstance);
return eventInstance;
}
private void CleanUp()
{
foreach (EventInstance eventInstance in eventInstances)
{
eventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
eventInstance.release();
}
}
private void OnDestroy()
{
CleanUp();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a2d525624a4586c4f903a2f0f33d0529
+25
View File
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
public class FMODEvents : MonoBehaviour
{
[field: Header("Jump SFX")]
[field: SerializeField] public EventReference jumped { get; private set; }
[field: Header("Die SFX")]
[field: SerializeField] public EventReference died { get; private set; }
[field: Header("Level Music")]
[field: SerializeField] public EventReference music { get; private set; }
public static FMODEvents instance { get; private set; }
private void Awake()
{
if (instance!=null)
{
Debug.LogError("Found more than one FMOD Events instance in the scene.");
}
instance = this;
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5400e43894b6a144aa6916a101fbf724