Goog afternoon everyone,
Sound settings is definitely not my cup of tea. My friend created a Master mixer and as children: music, SFX and Speech.
I followed this tutorial: https://adventurecreator.org/tutorials/working-audio-mixers
but the problem is that he wants 4 sliders: one for each type of sound. Now, for SFX, speech and music, all cool because they are default ones, but "how can I create one slider for the Master?".
I have created all 4 exposed parameters but I can't get to have the Master to appear under the Options settings in Menu.
What we are aiming for is volume control and the one missing would be the Master to show as a slider under options.
Please let me know if I'm not clear.
Unity 2020.3.27 and latest AC.
Thanks a lot
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
It'd be a case of linking the parameter - through script - to a Global Float Variable via Options Data, so that it can then be controlled through a Slider element.
The process of linking custom options data to variables is covered in this tutorial.
Attenuation parameters don't use the same scale as a 0 -> 1 volume slider, but you can run the conversion and update a given mixer automatically using the AdvGame.SetMixerVolume function.
Hello,
Thnak you very much. After a few days of work I made it work but not the tutorial way. This is what I did:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using AC;
using UnityEngine.UI;
public class AudioMaster : MonoBehaviour
{
private GVar masterVolumeVar;
public float masterVolume;
//public string masterVolumeString;
public AudioMixer mixer;
//public Slider theSlider;
So, this comes to a GameObject (prefab) on screen. The "mixer" parameter is the main mixer we have in Unity. As for the menus and Variable, our custom float variable is 28 as you can see. Then, linked it to options and linked the slider to the menu. Nothing else.
I started doing the tutorial way but I found that it never ran from start. This is the script I did for this.
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Audio;
using UnityEditor;
using AC;
namespace AC
{
[System.Serializable]
public class AudioMasterTemplate : Action
{
// Declare properties here
public override ActionCategory Category { get { return ActionCategory.Engine; }}
public override string Title { get { return "Master volume"; }}
public override string Description { get { return "This is a Master volume."; }}
}
I'm perry sure it's super wrong. I can see the Engine.Master Volume but does nothing when called. I has nothing but the option to choose the mixer. There has to be something wrong because the slider and variable work but it does nothing when calling it from start (sorry, touching new grounds with this topic).
First I want to understand where I'm doing wrong. Maybe I can get rid of the gameObject on screen?
Secondly: I honestly didn't understand this AC.AdvGame.SetMixerVolume. What should be the parameters and where should it go?
And third: I found that AC default SFX, music and speech options go from 0 to 1 when "changing volume" but my friend is all about attenuation. Any way I can see what attenuation is eaqul to in terms of the 0 to 1 float? (I don't even know where I'm going with this question hahaha).
Thanks a lot.
Action scripts don't derive from Unity's MonoBehaviour - Start and Update won't be called automatically in the same way. An Action is only run when called in an ActionList, and the code that affects the scene should be placed in the Run function:
To have an Action run when your game starts, place it in your "ActionList on start game" asset, assigned in the Settings Manager:
SetMixerVolume automatically converts a 0 -> 1 volume slider scale into an attenuation value. If your float variable uses this scale, replace your audioMixer.SetFloat with:
The conversion can be found inside the SetMixerVolume function:
Thank you very much. Now it's more clear. Just one thought: do you know our way of doing it can kill performance is not good even if it worked? It's just to read an opinion because for us, we did brightness exactly the same way and so far, it works. The only thing is: you need to have a prefab gameobject present in all scenes.
Thanks a lot!
Forgot to ask: those last two lines: where should they go? In the AL script? In an object present in scenes? Update() or method?
Thanks again.
The custom Action avoids the need for a prefab / script in the scene.
The SetMixerVolume call, if you want to use it, should replace the mixer's SetFloat call in the Action's Run function.
The conversion line was to answer your question of how to get the attenuation from a 0 -> 1 scale - it's not necessary for the Action to work.
Thank you so much. Hope this script serves good for future adventurers