added audio stuffs

This commit is contained in:
cyndrdev 2021-03-05 18:22:18 +00:00
parent 4ca7a5b91b
commit 34352d95ab
6 changed files with 105 additions and 14 deletions

View File

@ -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

View File

@ -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}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c0da1dab89beefe4097416b015f6025a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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();
}
}

View File

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

View File

@ -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<string> _usedClips = new List<string>();
private EVENT_CALLBACK _dialogueCallback;
private EventInstance _currentInstance;
private void OnEnable()
{
@ -119,10 +121,16 @@ public partial class DialogueSystem : ScriptableObject
_usedClips.Add(key);
}
var dialogueInstance = RuntimeManager.CreateInstance(_settings.RadioDialogueKey);
if ( _currentInstance.isValid() )
{
_currentInstance.stop( STOP_MODE.IMMEDIATE );
_currentInstance.release();
}
_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);
}