1
0
forked from cgvr/DeltaVR

added initial logic for the volume sliders

This commit is contained in:
Timur Nizamov
2025-12-02 22:40:17 +02:00
parent 0b4854373b
commit f414e10d94
43 changed files with 365 additions and 422 deletions
@@ -110,8 +110,8 @@ public class CarDrivingRoutine : NetworkBehaviour
{; {;
if (other.GetComponentInParent<XRPlayerMirror>() == null) return; if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
StartCoroutine(SmoothAdjustSpeed(0, 0, haltspeed)); // Smoothly halt in 1 second StartCoroutine(SmoothAdjustSpeed(0, 0, haltspeed)); // Smoothly halt in 1 second
_tireSound.Stop(); //_tireSound.Stop();
_stopSound.Play(); //_stopSound.Play();
AudioController.SetRPM(475); AudioController.SetRPM(475);
AudioController.PlayStopSound(); AudioController.PlayStopSound();
@@ -122,8 +122,8 @@ public class CarDrivingRoutine : NetworkBehaviour
{ {
if (other.GetComponentInParent<XRPlayerMirror>() == null) return; if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
StartCoroutine(SmoothAdjustSpeed(targetSpeed, targetRotationSpeed, haltspeed)); // Smoothly resume speed in 1 second StartCoroutine(SmoothAdjustSpeed(targetSpeed, targetRotationSpeed, haltspeed)); // Smoothly resume speed in 1 second
_stopSound.Stop(); //_stopSound.Stop();
_tireSound.Play(); //_tireSound.Play();
AudioController.SetRPM(1450); AudioController.SetRPM(1450);
@@ -694,6 +694,7 @@ GameObject:
- component: {fileID: 5331342604379454603} - component: {fileID: 5331342604379454603}
- component: {fileID: 1866864886208815} - component: {fileID: 1866864886208815}
- component: {fileID: 6596783065788885589} - component: {fileID: 6596783065788885589}
- component: {fileID: 2714778319450199886}
m_Layer: 5 m_Layer: 5
m_Name: Button m_Name: Button
m_TagString: Untagged m_TagString: Untagged
@@ -820,6 +821,19 @@ MonoBehaviour:
minValue: 0 minValue: 0
maxValue: 1 maxValue: 1
slideareaOffsetMultiplier: 0.9 slideareaOffsetMultiplier: 0.9
--- !u!114 &2714778319450199886
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 829665037849699668}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 2
--- !u!1 &829695359259357513 --- !u!1 &829695359259357513
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -1465,6 +1479,7 @@ GameObject:
- component: {fileID: 8149783172932780154} - component: {fileID: 8149783172932780154}
- component: {fileID: 7017778607745474649} - component: {fileID: 7017778607745474649}
- component: {fileID: 2708450618333126782} - component: {fileID: 2708450618333126782}
- component: {fileID: 6631830758558507073}
m_Layer: 5 m_Layer: 5
m_Name: Button m_Name: Button
m_TagString: Untagged m_TagString: Untagged
@@ -1591,6 +1606,19 @@ MonoBehaviour:
minValue: 0 minValue: 0
maxValue: 1 maxValue: 1
slideareaOffsetMultiplier: 0.9 slideareaOffsetMultiplier: 0.9
--- !u!114 &6631830758558507073
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1371473744446131600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 3
--- !u!1 &1451224546718335135 --- !u!1 &1451224546718335135
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -4720,6 +4748,7 @@ GameObject:
- component: {fileID: 3702309226689803558} - component: {fileID: 3702309226689803558}
- component: {fileID: 6841033323124689675} - component: {fileID: 6841033323124689675}
- component: {fileID: 6619092689880446435} - component: {fileID: 6619092689880446435}
- component: {fileID: 5831180822224317918}
m_Layer: 5 m_Layer: 5
m_Name: Button m_Name: Button
m_TagString: Untagged m_TagString: Untagged
@@ -4846,6 +4875,19 @@ MonoBehaviour:
minValue: 0 minValue: 0
maxValue: 1 maxValue: 1
slideareaOffsetMultiplier: 0.9 slideareaOffsetMultiplier: 0.9
--- !u!114 &5831180822224317918
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4757451720330744469}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 0
--- !u!1 &4815518641921404370 --- !u!1 &4815518641921404370
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -6575,6 +6617,7 @@ GameObject:
- component: {fileID: 6392076320775958587} - component: {fileID: 6392076320775958587}
- component: {fileID: 8533604835838269795} - component: {fileID: 8533604835838269795}
- component: {fileID: 221982658494184569} - component: {fileID: 221982658494184569}
- component: {fileID: 5486814484665002793}
m_Layer: 5 m_Layer: 5
m_Name: Button m_Name: Button
m_TagString: Untagged m_TagString: Untagged
@@ -6701,6 +6744,19 @@ MonoBehaviour:
minValue: 0 minValue: 0
maxValue: 1 maxValue: 1
slideareaOffsetMultiplier: 0.9 slideareaOffsetMultiplier: 0.9
--- !u!114 &5486814484665002793
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6661887633723237894}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 1
--- !u!1 &6802548334697868303 --- !u!1 &6802548334697868303
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -7952,6 +8008,7 @@ GameObject:
- component: {fileID: 7710393525849749537} - component: {fileID: 7710393525849749537}
- component: {fileID: 9065530914213283711} - component: {fileID: 9065530914213283711}
- component: {fileID: 1194791598480229312} - component: {fileID: 1194791598480229312}
- component: {fileID: 7987415785522350763}
m_Layer: 5 m_Layer: 5
m_Name: Button m_Name: Button
m_TagString: Untagged m_TagString: Untagged
@@ -8078,6 +8135,19 @@ MonoBehaviour:
minValue: 0 minValue: 0
maxValue: 1 maxValue: 1
slideareaOffsetMultiplier: 0.9 slideareaOffsetMultiplier: 0.9
--- !u!114 &7987415785522350763
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8391231543345548430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 4
--- !u!1 &8436046511908584062 --- !u!1 &8436046511908584062
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -34,6 +34,18 @@ public class AudioSliderDragHandler : MonoBehaviour, IBeginDragHandler, IDragHan
UpdateSlider(eventData); UpdateSlider(eventData);
} }
public void SetHandlePosition(float normalizedValue)
{
float halfWidth = sliderBackground.rect.width * 0.5f;
float limit = halfWidth * slideareaOffsetMultiplier;
float x = Mathf.Lerp(-limit, limit, normalizedValue);
handleRect.localPosition = new Vector3(x, handleRect.localPosition.y, 0);
CurrentValue = normalizedValue;
}
public void OnDrag(PointerEventData eventData) public void OnDrag(PointerEventData eventData)
{ {
UpdateSlider(eventData); UpdateSlider(eventData);
@@ -46,6 +58,7 @@ public class AudioSliderDragHandler : MonoBehaviour, IBeginDragHandler, IDragHan
} }
private void UpdateSlider(PointerEventData eventData) private void UpdateSlider(PointerEventData eventData)
{ {
Debug.Log("UpDating Slider"); Debug.Log("UpDating Slider");
Vector2 localPoint; Vector2 localPoint;
RectTransformUtility.ScreenPointToLocalPointInRectangle(sliderBackground, eventData.position, eventData.pressEventCamera, out localPoint); RectTransformUtility.ScreenPointToLocalPointInRectangle(sliderBackground, eventData.position, eventData.pressEventCamera, out localPoint);
@@ -0,0 +1,80 @@
using UnityEngine;
public class SliderToVCA : MonoBehaviour
{
public enum VCATarget
{
Master,
Ambiences,
Music,
SFX,
UI
}
public VCATarget target;
private AudioSliderDragHandler slider;
private void Awake()
{
slider = GetComponent<AudioSliderDragHandler>();
}
private void Start()
{
float initialValue = GetInitialValueFromAudioManager();
slider.SetHandlePosition(initialValue); // we will add this function
}
private float GetInitialValueFromAudioManager()
{
switch (target)
{
case VCATarget.Master:
return AudioManager.Instance.MasterVolume;
case VCATarget.Ambiences:
return AudioManager.Instance.AmbienceVolume;
case VCATarget.Music:
return AudioManager.Instance.MusicVolume;
case VCATarget.SFX:
return AudioManager.Instance.SFXVolume;
case VCATarget.UI:
return AudioManager.Instance.UIVolume;
default:
return 1f;
}
}
private void Update()
{
// Constantly push slider value to the VCA
ApplyVolume(slider.CurrentValue);
Debug.Log("CurrentValue: " + slider.CurrentValue);
}
private void ApplyVolume(float value)
{
switch (target)
{
case VCATarget.Master:
AudioManager.Instance.SetMasterVCA(value);
Debug.LogError(value);
break;
case VCATarget.Ambiences:
AudioManager.Instance.SetAmbientVCA(value);
break;
case VCATarget.Music:
AudioManager.Instance.SetMusicVCA(value);
break;
case VCATarget.SFX:
AudioManager.Instance.SetSFXVCA(value);
break;
case VCATarget.UI:
AudioManager.Instance.SetUIVCA(value);
break;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebe1ab889a9bed940995d4f47bc743ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -123,7 +123,6 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 6021721823031538141} - component: {fileID: 6021721823031538141}
- component: {fileID: 4707456952479937532}
m_Layer: 0 m_Layer: 0
m_Name: Portal m_Name: Portal
m_TagString: Untagged m_TagString: Untagged
@@ -150,147 +149,6 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: -1 m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &4707456952479937532
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4777591596180506993}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 4d691c6581003c94bbfe74b21deb8784, type: 3}
m_PlayOnAwake: 1
m_Volume: 0.8
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 40
Pan2D: 0
rolloffMode: 2
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1.0028496
inSlope: -40.015934
outSlope: -40.015934
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.03449707
value: 0.49145508
inSlope: -10.0039835
outSlope: -10.0039835
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.1
value: 0.25
inSlope: -2.5009959
outSlope: -2.5009959
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.2
value: 0.125
inSlope: -0.62524897
outSlope: -0.62524897
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.4348816
value: 0.03970337
inSlope: -0.15631224
outSlope: -0.15631224
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.8
value: 0
inSlope: -0.03907806
outSlope: -0.03907806
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.9980469
value: 0
inSlope: -0.02500997
outSlope: -0.02500997
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &6014189720456933605 --- !u!1 &6014189720456933605
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -580,4 +438,4 @@ MonoBehaviour:
PlayerOcclusionWidening: 1 PlayerOcclusionWidening: 1
OcclusionLayer: OcclusionLayer:
serializedVersion: 2 serializedVersion: 2
m_Bits: 2048 m_Bits: 268438528
@@ -3,7 +3,16 @@ guid: 93a8cd8d2c83a1c4da7720c8a59fa706
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences:
- m_InteractionManager: {instanceID: 0}
- m_CustomReticle: {instanceID: 0}
- m_AttachTransform: {instanceID: 0}
- m_SecondaryAttachTransform: {instanceID: 0}
- pullMin: {instanceID: 0}
- pullMax: {instanceID: 0}
- pullSounds: {fileID: 11400000, guid: 3c359cbce1e053d4f97c86ed8998405b, type: 2}
- maxPullSounds: {fileID: 11400000, guid: a052046b894aee042a62bcc609a5afc7, type: 2}
- stringRenderer: {instanceID: 0}
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
@@ -1,3 +1,19 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5c49785f8ddb436bb890408012c0da7d guid: 5c49785f8ddb436bb890408012c0da7d
timeCreated: 1679237121 MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_InteractionManager: {instanceID: 0}
- m_AttachTransform: {instanceID: 0}
- m_StartingSelectedInteractable: {instanceID: 0}
- m_StartingTargetFilter: {instanceID: 0}
- m_InteractableHoverMeshMaterial: {instanceID: 0}
- m_InteractableCantHoverMeshMaterial: {instanceID: 0}
- nockSounds: {fileID: 11400000, guid: 6d1727a79cb00364c8adb70e8396e743, type: 2}
- releaseSounds: {fileID: 11400000, guid: 08fd7432471e0aa40b7a08f6d88b7281, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -115,4 +115,4 @@ MonoBehaviour:
Params: [] Params: []
OverrideAttenuation: 0 OverrideAttenuation: 0
OverrideMinDistance: 1 OverrideMinDistance: 1
OverrideMaxDistance: 5 OverrideMaxDistance: 8.8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+70 -63
View File
@@ -11,26 +11,42 @@ using STOP_MODE = FMOD.Studio.STOP_MODE;
public class AudioManager : MonoBehaviour public class AudioManager : MonoBehaviour
{ {
//VCAs (VCA buses) are mainly used for volume control
//Regular routing buses routing are for the remaining logic, for example, within the FMOD itself to put FMOD events inside the Mixer (Mixer Routing).
//Regular routing buses are used when we make some attenuation based on parameters and write the logic in code for Unity.
private VCA masterVCA;
private VCA musicVCA;
private VCA sfxVCA;
private VCA uiVCA;
private VCA ambienceVCA;
[SerializeField]
[Header("Volume")] [Header("Volume")]
[Range(0, 1)] [Range(0, 1)]
public float MasterVolume = 1; public float MasterVolume = 0.5f;
[Range(0, 1)] [Range(0, 1)]
public float MusicVolume = 1; public float MusicVolume = 0.5f;
[Range(0, 1)] [Range(0, 1)]
public float SFXVolume = 1; public float AmbienceVolume = 0.5f;
[Range(0, 1)] [Range(0, 1)]
public float UIVolume = 1; public float SFXVolume = 0.5f;
[Range(0, 1)]
public float UIVolume = 0.5f;
[Range(0, 1)] [Range(0, 1)]
private Bus masterBus; private Bus masterBus;
private Bus ambientBus;
private Bus musicBus; private Bus musicBus;
private Bus sfxBus; private Bus sfxBus;
private Bus reverbBus;
private Bus uiBus; private Bus uiBus;
const string sid = "00000000-0000-0000-0000-000000000000"; const string sid = "00000000-0000-0000-0000-000000000000";
static readonly Guid nullGuid = new Guid(sid); static readonly Guid nullGuid = new Guid(sid);
@@ -86,15 +102,47 @@ public class AudioManager : MonoBehaviour
_instance = instance; _instance = instance;
DontDestroyOnLoad(_instance.gameObject); DontDestroyOnLoad(_instance.gameObject);
_instance.eventInstances = new List<EventInstance>(); _instance.eventInstances = new List<EventInstance>();
_instance.masterBus = RuntimeManager.GetBus("bus:/"); _instance.masterBus = RuntimeManager.GetBus("bus:/");
_instance.musicBus = RuntimeManager.GetBus("bus:/Music"); _instance.musicBus = RuntimeManager.GetBus("bus:/Music");
_instance.ambientBus = RuntimeManager.GetBus("bus:/Ambiences");
_instance.sfxBus = RuntimeManager.GetBus("bus:/SFX"); _instance.sfxBus = RuntimeManager.GetBus("bus:/SFX");
_instance.uiBus = RuntimeManager.GetBus("bus:/UI"); _instance.uiBus = RuntimeManager.GetBus("bus:/UI");
// _instance.MasterVolume = SaveManager.Instance.systemData.MasterVolume / 100f;
// _instance.SFXVolume = SaveManager.Instance.systemData.SFXVolume / 100f;
// _instance.MusicVolume = SaveManager.Instance.systemData.MusicVolume / 100f;
// _instance.UIVolume = SaveManager.Instance.systemData.UIVolume / 100f;
_instance.masterVCA = RuntimeManager.GetVCA("vca:/Master");
_instance.musicVCA = RuntimeManager.GetVCA("vca:/Music");
_instance.ambienceVCA = RuntimeManager.GetVCA("vca:/Ambiences");
_instance.sfxVCA = RuntimeManager.GetVCA("vca:/SFX");
_instance.uiVCA = RuntimeManager.GetVCA("vca:/UI");
}
public void SetMasterVCA(float value)
{
masterVCA.setVolume(value);
}
public void SetMusicVCA(float value)
{
musicVCA.setVolume(value);
}
public void SetAmbientVCA(float value)
{
ambienceVCA.setVolume(value);
}
public void SetSFXVCA(float value)
{
sfxVCA.setVolume(value);
}
public void SetUIVCA(float value)
{
uiVCA.setVolume(value);
} }
private void Awake() private void Awake()
@@ -116,10 +164,19 @@ public class AudioManager : MonoBehaviour
private void Update() private void Update()
{ {
musicBus.setVolume(MusicVolume); //musicBus.setVolume(MusicVolume);
sfxBus.setVolume(SFXVolume); //ambientBus.setVolume(AmbienceVolume);
uiBus.setVolume(UIVolume); //sfxBus.setVolume(SFXVolume);
masterBus.setVolume(MasterVolume); //uiBus.setVolume(UIVolume);
//masterBus.setVolume(MasterVolume);
//VCA volumes
masterVCA.setVolume(MasterVolume);
ambienceVCA.setVolume(AmbienceVolume);
musicVCA.setVolume(MusicVolume);
sfxVCA.setVolume(SFXVolume);
uiVCA.setVolume(UIVolume);
} }
public static bool IsEventReferenceValid(EventReference eventReference) public static bool IsEventReferenceValid(EventReference eventReference)
@@ -190,17 +247,6 @@ public class AudioManager : MonoBehaviour
return; return;
} }
musicEventInstance = CreateInstance(musicEventReference); musicEventInstance = CreateInstance(musicEventReference);
timelineInfo = new TimelineInfo();
// Explicitly create the delegate object and assign it to a member so it doesn't get freed
// by the garbage collected while it's being used
beatCallback = new EVENT_CALLBACK(BeatEventCallback);
// Pin the class that will store the data modified during the callback
timelineHandle = GCHandle.Alloc(timelineInfo);
// Pass the object through the userdata of the instance
musicEventInstance.setUserData(GCHandle.ToIntPtr(timelineHandle));
musicEventInstance.setCallback(beatCallback, EVENT_CALLBACK_TYPE.TIMELINE_BEAT | EVENT_CALLBACK_TYPE.TIMELINE_MARKER);
} }
public void SetMusicParameter(string parameter, float value) public void SetMusicParameter(string parameter, float value)
@@ -278,45 +324,6 @@ public class AudioManager : MonoBehaviour
} }
} }
// taken from https://www.fmod.com/docs/2.02/unity/examples-timeline-callbacks.html
[AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))]
static FMOD.RESULT BeatEventCallback(EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)
{
EventInstance instance = new(instancePtr);
// Retrieve the user data
FMOD.RESULT result = instance.getUserData(out IntPtr timelineInfoPtr);
if (result != FMOD.RESULT.OK)
{
Debug.LogError("Timeline Callback error: " + result);
}
else if (timelineInfoPtr != IntPtr.Zero)
{
// Get the object to store beat and marker details
GCHandle timelineHandle = GCHandle.FromIntPtr(timelineInfoPtr);
TimelineInfo timelineInfo = (TimelineInfo)timelineHandle.Target;
switch (type)
{
case EVENT_CALLBACK_TYPE.TIMELINE_MARKER:
{
var parameter = (TIMELINE_MARKER_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(TIMELINE_MARKER_PROPERTIES));
timelineInfo.LastMarker = parameter.name;
OnNewBGMMarker?.Invoke(parameter.name);
break;
}
case EVENT_CALLBACK_TYPE.DESTROYED:
{
// Now the event has been destroyed, unpin the timeline memory so it can be garbage collected
timelineHandle.Free();
break;
}
}
}
return FMOD.RESULT.OK;
}
private void OnDestroy() private void OnDestroy()
{ {
CleanUp(); CleanUp();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -72,7 +72,7 @@
<value>2.60000014</value> <value>2.60000014</value>
</property> </property>
<property name="maximumDistance"> <property name="maximumDistance">
<value>70</value> <value>80</value>
</property> </property>
</object> </object>
<object class="MarkerTrack" id="{25ff9287-1371-4687-989c-3d2f2a0ae13a}" /> <object class="MarkerTrack" id="{25ff9287-1371-4687-989c-3d2f2a0ae13a}" />
@@ -74,7 +74,7 @@
<value>0.300000012</value> <value>0.300000012</value>
</property> </property>
<property name="maximumDistance"> <property name="maximumDistance">
<value>7.5999999</value> <value>8</value>
</property> </property>
</object> </object>
<object class="MarkerTrack" id="{aa5d1c19-51d6-46ff-b6b4-4f51346e9586}" /> <object class="MarkerTrack" id="{aa5d1c19-51d6-46ff-b6b4-4f51346e9586}" />
@@ -92,7 +92,6 @@
<relationship name="modules"> <relationship name="modules">
<destination>{60abf4e9-d905-4870-95be-7cc7256e0ebd}</destination> <destination>{60abf4e9-d905-4870-95be-7cc7256e0ebd}</destination>
<destination>{3193a222-e73f-43ef-baa2-702162771b3d}</destination> <destination>{3193a222-e73f-43ef-baa2-702162771b3d}</destination>
<destination>{d00b6226-a526-4d33-a9cf-9887b8564904}</destination>
</relationship> </relationship>
<relationship name="mixerGroup"> <relationship name="mixerGroup">
<destination>{48a9f589-80cf-4cee-9075-2fea6e720c8b}</destination> <destination>{48a9f589-80cf-4cee-9075-2fea6e720c8b}</destination>
@@ -121,7 +120,6 @@
<object class="Timeline" id="{e6b424c4-4c0c-4b73-a48b-c983751d6afb}"> <object class="Timeline" id="{e6b424c4-4c0c-4b73-a48b-c983751d6afb}">
<relationship name="modules"> <relationship name="modules">
<destination>{4aca6c13-361f-4739-a26a-e65479b2650c}</destination> <destination>{4aca6c13-361f-4739-a26a-e65479b2650c}</destination>
<destination>{d00b6226-a526-4d33-a9cf-9887b8564904}</destination>
<destination>{8df8f8fe-bb9d-45f0-90bf-98ca589e2991}</destination> <destination>{8df8f8fe-bb9d-45f0-90bf-98ca589e2991}</destination>
<destination>{b2f181eb-922d-4228-9e1f-f3ad9f9f36ef}</destination> <destination>{b2f181eb-922d-4228-9e1f-f3ad9f9f36ef}</destination>
</relationship> </relationship>
@@ -136,7 +134,7 @@
</object> </object>
<object class="EventMixerMaster" id="{6c5a6cd5-0ccc-458e-a3bd-cc8f730b3bef}"> <object class="EventMixerMaster" id="{6c5a6cd5-0ccc-458e-a3bd-cc8f730b3bef}">
<property name="volume"> <property name="volume">
<value>-3.5</value> <value>2.5</value>
</property> </property>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{f8c15184-15a1-4e9d-95b9-c95327204bfe}</destination> <destination>{f8c15184-15a1-4e9d-95b9-c95327204bfe}</destination>
@@ -229,14 +227,6 @@
<destination>{c3f81003-82b2-40ba-ae3f-58ea779ef4d4}</destination> <destination>{c3f81003-82b2-40ba-ae3f-58ea779ef4d4}</destination>
</relationship> </relationship>
</object> </object>
<object class="SingleSound" id="{d00b6226-a526-4d33-a9cf-9887b8564904}">
<property name="length">
<value>60.318604166666667</value>
</property>
<relationship name="audioFile">
<destination>{5dbb0efd-7f4d-4aa7-b6c5-4c42597ceb9f}</destination>
</relationship>
</object>
<object class="EventMixerGroup" id="{48a9f589-80cf-4cee-9075-2fea6e720c8b}"> <object class="EventMixerGroup" id="{48a9f589-80cf-4cee-9075-2fea6e720c8b}">
<property name="volume"> <property name="volume">
<value>-2</value> <value>-2</value>
@@ -280,7 +270,7 @@
</object> </object>
<object class="EventMixerGroup" id="{fea2c8c1-3229-41fc-8177-746e813179fc}"> <object class="EventMixerGroup" id="{fea2c8c1-3229-41fc-8177-746e813179fc}">
<property name="volume"> <property name="volume">
<value>-7.5</value> <value>-7</value>
</property> </property>
<property name="name"> <property name="name">
<value>Audio 3</value> <value>Audio 3</value>
@@ -321,7 +311,7 @@
</object> </object>
<object class="EventMixerGroup" id="{d6f26609-90ec-4a92-a6be-708ec2f94940}"> <object class="EventMixerGroup" id="{d6f26609-90ec-4a92-a6be-708ec2f94940}">
<property name="volume"> <property name="volume">
<value>-13.5</value> <value>-12</value>
</property> </property>
<property name="name"> <property name="name">
<value>Audio 4</value> <value>Audio 4</value>
@@ -492,7 +482,14 @@
</relationship> </relationship>
</object> </object>
<object class="MixerBusFader" id="{c9f62d4f-e959-41fc-a944-6b5ef12dcf83}" /> <object class="MixerBusFader" id="{c9f62d4f-e959-41fc-a944-6b5ef12dcf83}" />
<object class="SpatialiserEffect" id="{a81d6e01-b5b7-4122-a7b5-2cf3ae1fce34}" /> <object class="SpatialiserEffect" id="{a81d6e01-b5b7-4122-a7b5-2cf3ae1fce34}">
<property name="extentMode">
<value>1</value>
</property>
<property name="soundSize">
<value>14.5</value>
</property>
</object>
<object class="MultibandEqEffect" id="{a8be7296-cd96-4a66-828c-7d59efa175df}"> <object class="MultibandEqEffect" id="{a8be7296-cd96-4a66-828c-7d59efa175df}">
<property name="frequencyA"> <property name="frequencyA">
<value>19428.2324</value> <value>19428.2324</value>
@@ -78,7 +78,6 @@
<object class="MarkerTrack" id="{ebe51d68-94ca-4c6c-8e0a-5c76a6adec53}" /> <object class="MarkerTrack" id="{ebe51d68-94ca-4c6c-8e0a-5c76a6adec53}" />
<object class="GroupTrack" id="{08383708-a4ec-4ed4-b239-3bc763c83cd0}"> <object class="GroupTrack" id="{08383708-a4ec-4ed4-b239-3bc763c83cd0}">
<relationship name="modules"> <relationship name="modules">
<destination>{35c155d3-11a5-48b4-ba27-ebdb8b07dbd0}</destination>
<destination>{a3dd34ab-5519-4684-89b1-90ed93b19fc0}</destination> <destination>{a3dd34ab-5519-4684-89b1-90ed93b19fc0}</destination>
<destination>{82c380ac-3a25-4e9b-bc81-6dc156330c85}</destination> <destination>{82c380ac-3a25-4e9b-bc81-6dc156330c85}</destination>
</relationship> </relationship>
@@ -99,7 +98,6 @@
</object> </object>
<object class="Timeline" id="{a9418c0a-c15c-4523-8a31-2acc9d4bee1f}"> <object class="Timeline" id="{a9418c0a-c15c-4523-8a31-2acc9d4bee1f}">
<relationship name="modules"> <relationship name="modules">
<destination>{35c155d3-11a5-48b4-ba27-ebdb8b07dbd0}</destination>
<destination>{a8cea37b-82da-43cf-9f42-68ea15f177e4}</destination> <destination>{a8cea37b-82da-43cf-9f42-68ea15f177e4}</destination>
<destination>{98cd4dab-daa1-4146-a436-142a40961319}</destination> <destination>{98cd4dab-daa1-4146-a436-142a40961319}</destination>
</relationship> </relationship>
@@ -114,7 +112,7 @@
</object> </object>
<object class="EventMixerMaster" id="{d081d164-9b22-49da-9d30-6446d5c1a60a}"> <object class="EventMixerMaster" id="{d081d164-9b22-49da-9d30-6446d5c1a60a}">
<property name="volume"> <property name="volume">
<value>-4.5</value> <value>-9</value>
</property> </property>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{929b1c3e-951f-4cba-b573-a6725a0b69df}</destination> <destination>{929b1c3e-951f-4cba-b573-a6725a0b69df}</destination>
@@ -150,14 +148,6 @@
</relationship> </relationship>
</object> </object>
<object class="MixerBusPanner" id="{754a1107-5283-4e76-8000-9e2a43fe795e}" /> <object class="MixerBusPanner" id="{754a1107-5283-4e76-8000-9e2a43fe795e}" />
<object class="SingleSound" id="{35c155d3-11a5-48b4-ba27-ebdb8b07dbd0}">
<property name="length">
<value>58.328526077097507</value>
</property>
<relationship name="audioFile">
<destination>{68049f79-4a3e-48c1-88c9-b19082a26534}</destination>
</relationship>
</object>
<object class="TransitionSourceSound" id="{a3dd34ab-5519-4684-89b1-90ed93b19fc0}"> <object class="TransitionSourceSound" id="{a3dd34ab-5519-4684-89b1-90ed93b19fc0}">
<property name="length"> <property name="length">
<value>0.16</value> <value>0.16</value>
@@ -237,7 +227,7 @@
</object> </object>
<object class="EventMixerGroup" id="{eddef13d-d55e-4eb2-94c9-4584ca5065b1}"> <object class="EventMixerGroup" id="{eddef13d-d55e-4eb2-94c9-4584ca5065b1}">
<property name="volume"> <property name="volume">
<value>-11</value> <value>-8</value>
</property> </property>
<property name="name"> <property name="name">
<value>Audio 2</value> <value>Audio 2</value>
@@ -47,6 +47,9 @@
</relationship> </relationship>
</object> </object>
<object class="MixerInput" id="{bc89f87d-1eae-46c0-ba65-9dd10590fd79}"> <object class="MixerInput" id="{bc89f87d-1eae-46c0-ba65-9dd10590fd79}">
<relationship name="masters">
<destination>{6a1a7123-bd44-49b1-9092-22ef5bb105ec}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{aee070c5-4ff2-4594-bd41-12f059ad25d9}</destination> <destination>{aee070c5-4ff2-4594-bd41-12f059ad25d9}</destination>
</relationship> </relationship>
@@ -46,6 +46,9 @@
</relationship> </relationship>
</object> </object>
<object class="MixerInput" id="{7474ecf5-6dbb-4c39-8bf9-21e4c1a788d8}"> <object class="MixerInput" id="{7474ecf5-6dbb-4c39-8bf9-21e4c1a788d8}">
<relationship name="masters">
<destination>{162960f4-09a2-4526-a61e-7ac7e219d27d}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{b054d434-af8c-4e01-b1ce-bb88f7601e5b}</destination> <destination>{b054d434-af8c-4e01-b1ce-bb88f7601e5b}</destination>
</relationship> </relationship>
@@ -71,7 +71,7 @@
</object> </object>
<object class="EventAutomatableProperties" id="{01a7c570-5ee5-451c-b338-2928032226a4}"> <object class="EventAutomatableProperties" id="{01a7c570-5ee5-451c-b338-2928032226a4}">
<property name="maximumDistance"> <property name="maximumDistance">
<value>30</value> <value>50</value>
</property> </property>
</object> </object>
<object class="MarkerTrack" id="{831858f0-f689-4710-9a40-3246f1e5b327}" /> <object class="MarkerTrack" id="{831858f0-f689-4710-9a40-3246f1e5b327}" />
@@ -130,7 +130,7 @@
</object> </object>
<object class="EventMixerMaster" id="{11d0567a-a4de-4fe0-9531-f883ee95423b}"> <object class="EventMixerMaster" id="{11d0567a-a4de-4fe0-9531-f883ee95423b}">
<property name="volume"> <property name="volume">
<value>4</value> <value>7</value>
</property> </property>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{26251485-8b8f-4259-bc84-5fbf400ec338}</destination> <destination>{26251485-8b8f-4259-bc84-5fbf400ec338}</destination>
@@ -47,6 +47,9 @@
</relationship> </relationship>
</object> </object>
<object class="MixerInput" id="{4ee1c73d-3cc2-4ac6-86cc-1f23993a656e}"> <object class="MixerInput" id="{4ee1c73d-3cc2-4ac6-86cc-1f23993a656e}">
<relationship name="masters">
<destination>{162960f4-09a2-4526-a61e-7ac7e219d27d}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{8b684632-1faa-47ca-b017-08e3cd390e24}</destination> <destination>{8b684632-1faa-47ca-b017-08e3cd390e24}</destination>
</relationship> </relationship>
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>SFX</value> <value>SFX</value>
</property> </property>
<relationship name="masters">
<destination>{162960f4-09a2-4526-a61e-7ac7e219d27d}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{f7718f12-2a00-40d4-9061-39b5772aa050}</destination> <destination>{f7718f12-2a00-40d4-9061-39b5772aa050}</destination>
</relationship> </relationship>
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>Voiceovers</value> <value>Voiceovers</value>
</property> </property>
<relationship name="masters">
<destination>{7db632b8-c5c2-4e3e-ab97-f087b29d2976}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{18fe57ae-4110-48b9-92ff-598d3be28f6c}</destination> <destination>{18fe57ae-4110-48b9-92ff-598d3be28f6c}</destination>
</relationship> </relationship>
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>Car</value> <value>Car</value>
</property> </property>
<relationship name="masters">
<destination>{162960f4-09a2-4526-a61e-7ac7e219d27d}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{02d7cfc6-b23b-419e-b6b0-a0d3ff6f3b37}</destination> <destination>{02d7cfc6-b23b-419e-b6b0-a0d3ff6f3b37}</destination>
</relationship> </relationship>
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>UI</value> <value>UI</value>
</property> </property>
<relationship name="masters">
<destination>{6a1a7123-bd44-49b1-9092-22ef5bb105ec}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{e1a3bf76-f263-4ed7-b4a8-6777e50b4123}</destination> <destination>{e1a3bf76-f263-4ed7-b4a8-6777e50b4123}</destination>
</relationship> </relationship>
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>Ambiences</value> <value>Ambiences</value>
</property> </property>
<relationship name="masters">
<destination>{7db632b8-c5c2-4e3e-ab97-f087b29d2976}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{bd6035f4-9345-4a65-add5-a89f2d31f082}</destination> <destination>{bd6035f4-9345-4a65-add5-a89f2d31f082}</destination>
</relationship> </relationship>
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>Music</value> <value>Music</value>
</property> </property>
<relationship name="masters">
<destination>{3d7079dd-e886-4e28-bb4b-7466e809d6f0}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{6f63c73c-f73f-479c-9da3-d9c4efc3e3d0}</destination> <destination>{6f63c73c-f73f-479c-9da3-d9c4efc3e3d0}</destination>
</relationship> </relationship>
+3
View File
@@ -4,6 +4,9 @@
<property name="name"> <property name="name">
<value>Master Bus</value> <value>Master Bus</value>
</property> </property>
<relationship name="masters">
<destination>{abdd8187-ee40-4826-82f2-b919c3daf22c}</destination>
</relationship>
<relationship name="effectChain"> <relationship name="effectChain">
<destination>{5846e992-31e3-4ae3-ae44-d5e16aa2a367}</destination> <destination>{5846e992-31e3-4ae3-ae44-d5e16aa2a367}</destination>
</relationship> </relationship>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<objects serializationModel="Studio.02.03.00">
<object class="MixerVCA" id="{3d7079dd-e886-4e28-bb4b-7466e809d6f0}">
<property name="name">
<value>Music</value>
</property>
<relationship name="mixer">
<destination>{a1197cab-76c8-4da4-a41f-969ff1afdca4}</destination>
</relationship>
</object>
</objects>
@@ -4,9 +4,6 @@
<property name="name"> <property name="name">
<value>Ambiences</value> <value>Ambiences</value>
</property> </property>
<relationship name="masters">
<destination>{abdd8187-ee40-4826-82f2-b919c3daf22c}</destination>
</relationship>
<relationship name="mixer"> <relationship name="mixer">
<destination>{a1197cab-76c8-4da4-a41f-969ff1afdca4}</destination> <destination>{a1197cab-76c8-4da4-a41f-969ff1afdca4}</destination>
</relationship> </relationship>
+10 -10
View File
@@ -4,6 +4,10 @@
"name": "iopprnbb ,,p", "name": "iopprnbb ,,p",
"score": 491.0 "score": 491.0
}, },
{
"name": "mmmoo",
"score": 473.0
},
{ {
"name": "timmi", "name": "timmi",
"score": 469.0 "score": 469.0
@@ -36,6 +40,10 @@
"name": "Dabest", "name": "Dabest",
"score": 407.0 "score": 407.0
}, },
{
"name": "tgyhn",
"score": 376.0
},
{ {
"name": "rrc", "name": "rrc",
"score": 372.0 "score": 372.0
@@ -49,16 +57,8 @@
"score": 332.0 "score": 332.0
}, },
{ {
"name": "er", "name": "ftv",
"score": 164.0 "score": 212.0
},
{
"name": "fdgdggdd",
"score": 148.0
},
{
"name": "aa",
"score": 147.0
} }
] ]
} }