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

Possible to change Audio Source Output via Script?

Discussion in 'Audio & Video' started by lauchsuppe, Feb 10, 2016.

  1. lauchsuppe

    lauchsuppe

    Joined:
    Dec 6, 2014
    Posts:
    39
    Can't seem to find any information on this. Is it somehow possible to change the Audio Source Output to another MixerGroup via script?
     
    Waterman7 likes this.
  2. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
    maybe, but I KNOW you can expose the group volume level parameter by scripts. So you should be able to script a cross fade between mixer groups.

    https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/exposed-audiomixer-parameters


    Set up Input group
    Set up AudioSource output to Input group
    Set up OutGroup A
    Set up OutGroup B
    Create Receives on A and B
    Create Sends from Input to A and B
    Expose OutGroupA volume level parameter
    Expose OutGroupB volume level parameter

    Create a script that sets those variables as you wish..
     
  3. lauchsuppe

    lauchsuppe

    Joined:
    Dec 6, 2014
    Posts:
    39
    Thank you! That workaround should work!

    However, if there is a way to change the output (and therefore make use of the mixer hierachy ui) I'd still be interested to hear it.
     
  4. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
  5. lauchsuppe

    lauchsuppe

    Joined:
    Dec 6, 2014
    Posts:
    39
    Thanks so much! Now, the only question I'm left with is how to load an AudioMixerGroup from the Resources folder. Resources.Load("AudioMixer/AudioMixerGroup") doesn't return anything.
     
  6. Kinrai1

    Kinrai1

    Joined:
    Jan 1, 2018
    Posts:
    2
    I know this is super late, but I ended up using Resources.Load("AudioMixer/AudioMixerGroup") as AudioMixerGroup;