FMOD instance errors fix

This commit is contained in:
Timur Nizamov
2026-01-30 21:01:11 +02:00
parent 52701f3231
commit 5a13928a59
4 changed files with 37 additions and 15 deletions

View File

@@ -291,6 +291,11 @@ public class AudioManager : MonoBehaviour
}
public static void Pause()
{
musicEventInstance.setPaused(true);
}
//=====//
//=====//
@@ -323,6 +328,8 @@ public class AudioManager : MonoBehaviour
// Set the callback for programmer sounds
instance.setCallback(dialogueCallback);
bool managedByOcclusion = false;
// Add occlusion if available on the emitter
if (emitter != null)
{
@@ -330,12 +337,17 @@ public class AudioManager : MonoBehaviour
if (occlusion != null)
{
occlusion.InitialiseWithInstance(instance);
managedByOcclusion = true;
}
}
instance.start();
if (!managedByOcclusion)
{
instance.release();
}
}
[AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))]
@@ -414,11 +426,6 @@ public class AudioManager : MonoBehaviour
instance.setPaused(false);
}
public static void Pause()
{
musicEventInstance.setPaused(true);
}
public static void Pause(EventInstance instance)
{
instance.setPaused(true);
@@ -430,10 +437,12 @@ public class AudioManager : MonoBehaviour
{
foreach (EventInstance eventInstance in eventInstances)
{
if (eventInstance.isValid()) {
eventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
eventInstance.release();
}
}
}
}
private void OnDestroy()

View File

@@ -75,7 +75,7 @@ public class FirstPersonOcclusion : MonoBehaviour
AudioOccluded.start();
// 4. Releasing Instance (This allows the event to self-manage its lifetime, which is fine)
AudioOccluded.release();
//AudioOccluded.release();
managedInstances.Add(AudioOccluded); // ADDED
@@ -205,4 +205,17 @@ public class FirstPersonOcclusion : MonoBehaviour
}
}
}
private void OnDestroy()
{
// Stop & release all instances when this object is destroyed
foreach (var inst in managedInstances)
{
if (inst.isValid())
{
inst.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
inst.release();
}
}
managedInstances.Clear();
}
}

View File

@@ -8,6 +8,10 @@
"name": "timur",
"score": 486.0
},
{
"name": "taavi",
"score": 480.0
},
{
"name": "ppppVBBPPP",
"score": 478.0
@@ -55,10 +59,6 @@
{
"name": "yty",
"score": 446.0
},
{
"name": "lp",
"score": 444.0
}
]
}