Forum rules - please read before posting.

Controlling Mixer groups via menu

edited May 2017 in Technical Q&A
Hello there!

I have AC version 1.55a, with unity version 5.5.1f1 (64bit)

I have a Mixer for my game, which in turn has a bunch of groups (Narrator, Ambient, SFX, Dialogue, etc).

I want to be able to control each of the groups volumes via the Options Menu (create new sliders for each category and control while the game is paused). So I wanted to ask if that was possible in AC. 

I tried doing this. I set the audio settings in the settings tab of the AC Game Editor to Audio Mixers groups. I referenced the mixer's groups I wanted to control, and I exposed the groups attenuation variables so that they have the exact same name that appears in the audio setting, below the reference for the mixer groups.

Yet in the menu tab, when trying to set the slider to affect the Audio Mixer Groups, I still only get the option to affect the enums groups (SFX, speech, music), and when playing the game, the sliders seem to have no effect over the groups volume. Also, I was wondering if I can go to enum.cs and create new categories (or have the option to have more than just three mixer groups to control in the audio settings).

So if anybody knows what the best solution here is i'd really appreciate it!

Thanks in advance! 

Comments

  • edited May 2017
    Managed to fix the first problem, although I'm not sure why (it just started working)-.

    But I still wish to know wether I can meddle with the enum.cs and see that reflected on the choice for sliders in the menu. Right now, I know that if I add more categories to enum.cs, that means I can create audioSources and assign that category for them on their Sound.cs component. But I do not know how to make more slots for mixer groups appear on the audio settings (which I guess is what is making those new categories not show on the menu tab of AC Game Editor, when setting the sliders).
  • There's much more to the sound settings than the values that appear in Enums - I'm afraid you can't add more settings just by meddling there and there alone.

    You can, however, create custom options by linking variables to Options Data - see this tutorial.  Following the same principle:

    1) Link a Float variable to Options Data
    2) Write a new custom Action that changes the volume of the appropriate Mixer Group to the value of this variable (see the scripting guide's front page on how to read a variable's value).  Sounds with custom Mixer Groups should have their Sound type set to Other so that they're not overridden by SFX/Speech/Music
    3) Create a new Slider Menu element that is used to control the value of this variable
    4) Place your custom Action in an ActionList that runs when the Slider's value is changed
    5) Place your custom Action in an ActionList that runs when your game begins (top of the Settings Manager).
  • Thanks a lot for the help! I do have a couple more questions though:

    What I'm doing now is creating a custom action that changes the value of a Global Variable (set to Options Data). My problem comes with the referencing of the audioMixer.

    I imported the UnityEngine.Audio in the custom action, and defined a public variable mixer:

    public AudioMixer Mixer;

    but I have no idea where to link this variable with the real mixer. 
    this is my run method:

    override public float Run()
              {
                //ID de NarratorVolume GlobalVar: 9
                float Narratorvolume = GlobalVariables.GetFloatValue(9);

                Mixer.SetFloat("narratorVolume", Narratorvolume);
                return 0.0f;
              }

    I thought pherhaps the option to link would appear in the actionList tab, when choosing the custom action, but it didn't. 

    Thanks in advance!
  • edited May 2017
    To link a global variable to Options data you have to go to the Variables manager, and click on the variable in question. You will see a Link to: option with a drop down, there you can choose OptionsData. Now, a custom action is not a regular script, to show options in the Actionlist editor you will have to go to the ShowGUI method and use GUI or EditorGUILayout methods to create the UI. I advice you to take a look at the "writing custom actions" tutorials to see how it works. You'll use the same UI method shown in the tutorial to read regular gameobjects, you'll just need to cast this to Mixer class instead.... or you can get a regular gameobject, just like in the tutorial, and then use a GetComponent to get the mixer). 

    Another way to do this, AC can also take Mixers in its audio settings, so I'm sure there must be a property or method to reference, try taking a look at the API.
  • edited May 2017
    You will need to implement an override of the ActionTemplate's ShowGUI function, as demonstrated in the custom Action tutorial.

    To expose the mixer specifically, write:

    Mixer = (AudioMixer) EditorGUILayout.ObjectField ("Mixer:", Mixer, typeof (AudioMixer), false);
  • Thanks a lot, now it works! (almost, sounds do not play when changed from SFX to Other, but I'll check in case its something else)
  • Be sure to update to v1.57, as this fixed an issue with "Other" sounds.
  • Oh ok, I will upgrade as soon as I can (gotta check with the team first)
  • edited May 2017
    Hey there! I have a new issue. Was going to open a new discussion, but since it is related to this subject, I thought it better be here:

    I updated AC to 1.57, and it works great. I can control any mixer group I want with the menu sliders. Also, the sounds set to "Other" now play allright, so all ok there.

    But now, everytime I pause during a cutscene, the cutscene times get all messed up. For example: 

    I have an OnStart cutscene which consists on a camera gliding through a big stage, while a narrator clip plays. The cutscene ends with the camera reaching and focusing on the player, and the player being animated to wave. The camera gliding is managed using the Camera: switch action, with a transition time of 15 seconds (which is how long the narrator clip lasts).


    But now, If I press esc during the cutscene (to bring up the pause menu), and then unpause, the camera goes in a flash to focus the player and play his animation, ignoring the transition time of 15 (even if the pausing lasted less than a second)- The Narrator keeps playing, but the camera is already set on the player.


    For further details. The Camera switch happens first, with wait until finish not checked. then, the narrator clip is played, and that one has the wait until finished check. So the problem as I see it is that it is not waiting for the narrator to finish (image below)

    image


    So my question is what could be causing this. it does not happen in other scenes (even though they all have the same sort of OnStart cutscenes with narrators and everything). And If I do not press esc, then the cutscene runs allright from start to end.

    Thanks in advance!
  • So is it just this Cutscene that's affected, and was this behaviour introduced in v1.57?

    I can't recreate the issue, but does it work if you set a specific camera to switch to, as opposed to "last gameplay"?

    Be aware that an alternative way to do this would be to precede both Actions with an Engine: Run in parallel Action that can be used to begin both the Camera: Switch and the Dialogue: Play speech Action simultaneously.  You can then check Wait until finish? on the Camera: Switch (if desired) without it affecting the timer of the other.
  • So is it just this Cutscene that's affected, and was this behaviour introduced in v1.57?

    Yes, only this cutscene. Before this I had version 1.55a, and I remember a similar problem ocurring in the same scene (although at that time every sound set to other did not play, so I did not really got to worry about the cutscene).


    Does it work if you set a specific camera to switch to, as opposed to "last gameplay"?

    No, that did not work (created a duplicate of navcam with a different id, and replaced the return to gameplay for that camera, but the problem kept popping).


    An alternative way to do this would be to precede both Actions with an Engine: Run in parallel Action that can be used to begin both the Camera: Switch and the Dialogue: Play speech Action simultaneously

    Engine doesnt give me an option for run in parallel :(

    --------------------

    I found a solution! No idea why this works though, but what I did was exchange the order of the Camera: Switch with the Sound: Play, and unchecked the wait for finish from the Sound and checked it in the Camera: Switch. there could be something there (a reason why it doesn't wait for the clip to completely run).

    Thanks for all the help!!
  • Apologies - I meant ActionList: Run in parallel.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.