fmod added & sound working
This commit is contained in:
46
Assets/8_Scripts/1_Managers/AudioManager.cs
Normal file
46
Assets/8_Scripts/1_Managers/AudioManager.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FMODUnity;
|
||||
using FMOD.Studio;
|
||||
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
public static AudioManager instance { get; private set; }
|
||||
[SerializeField] public EventReference m_Soundtrack;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null)
|
||||
Debug.LogError("Found more than one Audio Manager in the scene");
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//StartSoundtrack();
|
||||
Time.timeScale = .75f;
|
||||
}
|
||||
|
||||
public void StartSoundtrack()
|
||||
{
|
||||
if (!m_Soundtrack.IsNull)
|
||||
{
|
||||
RuntimeManager.PlayOneShot(m_Soundtrack);
|
||||
}
|
||||
}
|
||||
|
||||
public EventInstance PlaySound(EventReference sound)
|
||||
{
|
||||
EventInstance soundInst = RuntimeManager.CreateInstance(sound);
|
||||
soundInst.start();
|
||||
return soundInst;
|
||||
}
|
||||
|
||||
public void StopSound(EventInstance soundInst)
|
||||
{
|
||||
soundInst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
|
||||
soundInst.release();
|
||||
soundInst.clearHandle();
|
||||
}
|
||||
}
|
||||
11
Assets/8_Scripts/1_Managers/AudioManager.cs.meta
generated
Normal file
11
Assets/8_Scripts/1_Managers/AudioManager.cs.meta
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2f2b9ea71903e74f9f1e3023ebc6765
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -30,7 +30,8 @@ public class NarrationManager : MonoBehaviour
|
||||
{
|
||||
if (_instance != null)
|
||||
Destroy(this);
|
||||
DontDestroyOnLoad(this);
|
||||
else
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
// Read in a text file, split into sentences, and add to list.
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
using Mono.Cecil;
|
||||
using FMOD.Studio;
|
||||
using FMODUnity;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.ParticleSystem;
|
||||
|
||||
public class SubtitleManager : MonoBehaviour
|
||||
{
|
||||
[Header("Text")]
|
||||
public TMP_Text m_Text;
|
||||
[Header("Audio")]
|
||||
[Header("Audio")]
|
||||
[SerializeField]
|
||||
private EventReference m_NarrationSFX;
|
||||
[SerializeField]
|
||||
private EventInstance m_NarrationSFXInst;
|
||||
|
||||
private float m_TimeElapsed;
|
||||
|
||||
@@ -35,25 +40,25 @@ public class SubtitleManager : MonoBehaviour
|
||||
|
||||
private void UpdateText(string sentence, float waitTime)
|
||||
{
|
||||
//FMOD.Studio.PLAYBACK_STATE state;
|
||||
FMOD.Studio.PLAYBACK_STATE state;
|
||||
|
||||
//m_NarrationSFXInst = AudioManager.instance.PlaySound(m_NarrationSFX);
|
||||
m_NarrationSFXInst = AudioManager.instance.PlaySound(m_NarrationSFX);
|
||||
|
||||
//m_NarrationSFXInst.getPlaybackState(out state);
|
||||
m_NarrationSFXInst.getPlaybackState(out state);
|
||||
|
||||
//if (m_FirstRun)
|
||||
//{
|
||||
// m_FirstRun = false;
|
||||
// m_NarrationSFXInst.start();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// m_NarrationSFXInst.getPlaybackState(out state);
|
||||
// if (state == PLAYBACK_STATE.STOPPED)
|
||||
// {
|
||||
// m_NarrationSFXInst.start();
|
||||
// }
|
||||
//}
|
||||
if (m_FirstRun)
|
||||
{
|
||||
m_FirstRun = false;
|
||||
m_NarrationSFXInst.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NarrationSFXInst.getPlaybackState(out state);
|
||||
if (state == PLAYBACK_STATE.STOPPED)
|
||||
{
|
||||
m_NarrationSFXInst.start();
|
||||
}
|
||||
}
|
||||
StartCoroutine(TextScroll(sentence, waitTime));
|
||||
}
|
||||
|
||||
@@ -74,7 +79,7 @@ public class SubtitleManager : MonoBehaviour
|
||||
earlyOffset = offset / Random.Range(2, 4);
|
||||
offset -= earlyOffset;
|
||||
yield return new WaitForSecondsRealtime(earlyOffset);
|
||||
//AudioManager.instance.StopSound(m_NarrationSFXInst);
|
||||
AudioManager.instance.StopSound(m_NarrationSFXInst);
|
||||
}
|
||||
yield return new WaitForSecondsRealtime(offset);
|
||||
m_Text.text = "";
|
||||
@@ -104,7 +109,7 @@ public class SubtitleManager : MonoBehaviour
|
||||
// // Stop audio early based on probability
|
||||
// if (randomStoppingValue == index && earlyStop)
|
||||
// {
|
||||
// //AudioManager.instance.StopSound(m_NarrationSFXInst);
|
||||
// AudioManager.instance.StopSound(m_NarrationSFXInst);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
what sphinx of cement and aluminum bashed open their skulls and ate up their brains and imagination?
|
||||
moloch
|
||||
solitude
|
||||
|
||||
Reference in New Issue
Block a user