diff --git a/game/Assets/Scenes/Boot.unity b/game/Assets/Scenes/Boot.unity index e5a2f3a..7747936 100644 --- a/game/Assets/Scenes/Boot.unity +++ b/game/Assets/Scenes/Boot.unity @@ -274,7 +274,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1261297785 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index b36c748..1f7fbc9 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -2562,19 +2562,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.w - value: 0.98881716 + value: 0.9887962 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.x - value: 0.1419703 + value: 0.1419673 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: 0.04519987 + value: 0.045656655 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: -0.0064896117 + value: -0.0065551954 objectReference: {fileID: 0} - target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_Name @@ -2690,19 +2690,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.w - value: 0.98881716 + value: 0.9887962 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.x - value: 0.14197028 + value: 0.14196727 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: 0.04519986 + value: 0.045656648 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: -0.006489608 + value: -0.006555192 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} @@ -2721,6 +2721,50 @@ Transform: m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: e20114b5c13a067488940c5cc8e13b60, type: 3} m_PrefabInstance: {fileID: 3060674078300009146} m_PrefabAsset: {fileID: 0} +--- !u!1 &786990804 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 786990805} + - component: {fileID: 786990806} + m_Layer: 0 + m_Name: MusicManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &786990805 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 786990804} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 11 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &786990806 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 786990804} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 27f3f5345a3cb684195f070b3d44bc05, type: 3} + m_Name: + m_EditorClassIdentifier: + _musicId: event:/Music/WIPMusic --- !u!1 &797647646 stripped GameObject: m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 506f92c064b9c494f981ac4216e033a8, type: 3} diff --git a/game/Assets/Scripts/Audio.meta b/game/Assets/Scripts/Audio.meta new file mode 100644 index 0000000..9a9a845 --- /dev/null +++ b/game/Assets/Scripts/Audio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c0da1dab89beefe4097416b015f6025a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Audio/MusicManager.cs b/game/Assets/Scripts/Audio/MusicManager.cs new file mode 100644 index 0000000..416d01c --- /dev/null +++ b/game/Assets/Scripts/Audio/MusicManager.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using FMOD; +using FMOD.Studio; +using FMODUnity; + +public class MusicManager : MonoBehaviour +{ + [SerializeField] + [EventRef] + private string _musicId; + + private EventInstance _musicInstance; + + void Start() + { + _musicInstance = RuntimeManager.CreateInstance( _musicId ); + _musicInstance.start(); + } +} diff --git a/game/Assets/Scripts/Audio/MusicManager.cs.meta b/game/Assets/Scripts/Audio/MusicManager.cs.meta new file mode 100644 index 0000000..7897282 --- /dev/null +++ b/game/Assets/Scripts/Audio/MusicManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 27f3f5345a3cb684195f070b3d44bc05 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Dialogue/DialogueSystem.cs b/game/Assets/Scripts/Dialogue/DialogueSystem.cs index 062f4ad..abf7d10 100644 --- a/game/Assets/Scripts/Dialogue/DialogueSystem.cs +++ b/game/Assets/Scripts/Dialogue/DialogueSystem.cs @@ -9,6 +9,7 @@ using UnityEngine; using UnityEngine.Animations.Rigging; using UnityEngine.Networking; using Debug = UnityEngine.Debug; +using STOP_MODE = FMOD.Studio.STOP_MODE; #if UNITY_EDITOR using UnityEditor; @@ -26,6 +27,7 @@ public partial class DialogueSystem : ScriptableObject private readonly List _usedClips = new List(); private EVENT_CALLBACK _dialogueCallback; + private EventInstance _currentInstance; private void OnEnable() { @@ -118,11 +120,17 @@ public partial class DialogueSystem : ScriptableObject _usedClips.Add(key); } + + if ( _currentInstance.isValid() ) + { + _currentInstance.stop( STOP_MODE.IMMEDIATE ); + _currentInstance.release(); + } - var dialogueInstance = RuntimeManager.CreateInstance(_settings.RadioDialogueKey); + _currentInstance = RuntimeManager.CreateInstance(_settings.RadioDialogueKey); GCHandle stringHandle = GCHandle.Alloc(key, GCHandleType.Pinned); - dialogueInstance.setUserData(GCHandle.ToIntPtr(stringHandle)); + _currentInstance.setUserData(GCHandle.ToIntPtr(stringHandle)); DialogueLine dl; dl.text = DialogueDatabase.ReadDialogue(key); @@ -130,9 +138,8 @@ public partial class DialogueSystem : ScriptableObject var clip = _settings.GetDialogueClip(key); dl.duration = clip.length; - dialogueInstance.setCallback(_dialogueCallback); - dialogueInstance.start(); - dialogueInstance.release(); + _currentInstance.setCallback(_dialogueCallback); + _currentInstance.start(); onDialogueLine?.Invoke(this, dl); }