Answered
0
0

I need to stop and release all playing sound with FMOD, essentially repair it to its original initialization state when the player quits to the main menu. I tried deleting the runtime manager, but it causes Unity to explode when I try to call it again. Does FMOD have a magical command on the runtime manager such as RuntimeManager.Reset(). Not seeing any commands to reset FMOD back to its starting state and stop all playing sounds.

I feel like this should be dirt simple. Is there a hidden command somewhere? I’m fairly knew to FMOD so any help is appreciated.

  • You must to post comments
Best Answer
0
0

As far as I can tell the RuntimeManager needs to be nuked and reset in order to properly wipe everything. You can call System.Release, but then it won’t run the full proper setup on the manager next time it’s called.

My solution was the following to trick the RuntimeManager into fully resetting itself the next time it’s called. I had to use reflection, but IMO the RuntimeManager should come with a simple “Reset” method that does this.

using System.Collections;
using System.Reflection;
using FMODUnity;
using UnityEngine;

    public class HardReset : MiscClass {
        protected override IEnumerator OnFinish () {
            var go = GameObject.Find("FMOD.UnityItegration.RuntimeManager");
            Destroy(go);

            // Skip a frame to allow full destruction
            yield return null;

            // Manually wipe isQuitting to prevent false positive errors from firing
            // This allows the RuntimeManager to perform a full initialization next time it's called
            var field = typeof(RuntimeManager).GetField("isQuitting",
                BindingFlags.Static |
                BindingFlags.NonPublic);

            if (field != null) {
                field.SetValue(null, false);
            } else {
                Debug.LogWarning("Could not find RuntimeManager.isQuitting");
            }
        }
    }
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.