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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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.