Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Changing volume on a group?

Discussion in 'Audio & Video' started by Kovenant, Apr 28, 2015.

  1. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    I'm trying to change the volume of a group by code, but I can't seem to access the volume information?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Audio;
    4.  
    5. public class GameSettings : MonoBehaviour {
    6.  
    7.     public AudioMixerGroup musicGroup;
    8.     [Range(0, 1)] public float musicVolume;
    9.  
    10. }
    11.  
    I've assigned musicGroup properly...
     
  2. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    Read about exposed parameters in the docs - GetFloat and SetFloat to be precise. You'll be able to tweak gain using those.