Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Help with making settings menu using FMOD?

Discussion in 'Formats & External Tools' started by jrad327, Jan 2, 2020.

  1. jrad327

    jrad327

    Joined:
    May 2, 2018
    Posts:
    4
    DISCLAIMER: FMOD is new to me and therefore, I am not particularly experienced in it, What I've learned to code of it so far has mostly been from threads in the 'QA' forums and a few YouTube tutorials (and yes, the documentation as well, although... It isn't exactly as expansive as the Unity Documentation, which is honestly a tad frustrating.

    EDIT: I am using Unity 2019.1f with the latest version of the FMOD Integration, hopefully, this helps clarify things a little bit.

    Anyway: I've been trying to improve the quality of my game audio by using the FMOD Unity Integration, I have a settings menu that controls the video settings (resolution, post-processing effects and such), And a section dedicated to reconfiguring the Audio, ya know.. Music, SFX, Ambient, Master.. things like that.

    In addition, I have a playlist controlling the music on the title screen (a Multi-Instrument event around 41 minutes long, containing about 10 songs, set to loop when the playlist is done, sequential order) However: I really want to be able to skip the currently playing song and have the ability to go to the previous song (when applicable)

    There's a problem with all of this.

    Currently, the audio slider doesn't really do ANYTHING...they're a lot more like visual eye-candy than useful user interface elements. This is an undesired behavior.

    NOTE: The audio sliders should be controlling the volume of their respective bus, Master being the exception: as it should control all buses at the same time.

    If it helps any; I'm currently following this tutorial: https://www.youtube.com/watch?v=yQgVKR6PMq

    (code below)
    AudioSettings.cs
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class AudioSettings : MonoBehaviour
    6. {
    7.     FMOD.Studio.EventInstance seTestEvent;
    8.  
    9.     FMOD.Studio.Bus Master;
    10.     FMOD.Studio.Bus Bgm;
    11.     FMOD.Studio.Bus Se;
    12.     float bgmVolume = 0.5f;
    13.     float seVolume = 0.5f;
    14.     float masterVolume = 1f;
    15.  
    16.     void Awake()
    17.     {
    18.         Bgm = FMODUnity.RuntimeManager.GetBus("bus:/Master/Bgm");
    19.         Se = FMODUnity.RuntimeManager.GetBus("bus:/Master/Se");
    20.         Master = FMODUnity.RuntimeManager.GetBus("bus:/Master");
    21.         seTestEvent = FMODUnity.RuntimeManager.CreateInstance("event:/sfx/mouseclick");
    22.     }
    23.  
    24.     void Update()
    25.     {
    26.         Bgm.setVolume(bgmVolume);
    27.         Se.setVolume(seVolume);
    28.         Master.setVolume(masterVolume);
    29.     }
    30.  
    31.     public void MasterVolumeLevel(float newMasterVolume)
    32.     {
    33.         masterVolume = newMasterVolume;
    34.     }
    35.  
    36.     public void BgmVolumeLevel(float newBgmVolume)
    37.     {
    38.         bgmVolume = newBgmVolume;
    39.     }
    40.  
    41.     public void SeVolumeLevel(float newSeVolume)
    42.     {
    43.         seVolume = newSeVolume;
    44.  
    45.         FMOD.Studio.PLAYBACK_STATE pbState;
    46.         seTestEvent.getPlaybackState(out pbState);
    47.         if (pbState != FMOD.Studio.PLAYBACK_STATE.PLAYING)
    48.         {
    49.             seTestEvent.start();
    50.         }
    51.     }
    52. }
     
    Last edited: Jan 3, 2020
  2. jrad327

    jrad327

    Joined:
    May 2, 2018
    Posts:
    4
  3. alexzen

    alexzen

    Joined:
    Jan 26, 2017
    Posts:
    1
    Can't replicate, check with a Debug.Log() if your values are changing when moving the slider. Probably you just forgot to select the dynamic float parameter:

    upload_2020-1-4_18-4-11.png

    If not check what Bus.setVolume returns. It should return OK:

    Code (CSharp):
    1.     void Update()
    2.     {
    3.      var result = bus.setVolume(busVolume);
    4.      Debug.Log(result);
    5.     }
    Regarding your second question, you can't do that with a multi instrument. Try to create an Event with a Skip and Back parameter and skip return to songs with transition regions with conditions based on these parameters:

    songskip.PNG

    Another option is to have one Event per song and manage a playlist with code in Unity.
     
  4. jrad327

    jrad327

    Joined:
    May 2, 2018
    Posts:
    4
    apologies for the late reply, man. thanks for your help! this ultimately got the playlist working. :)