Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
2
Question by okkal11 · Apr 18, 2015 at 08:39 PM · c#audioaudiosourcemixing

C# Setting AudioMixerGroup through code

I have a Mixer with a group called 'ExplosivesGroup' it´s in the group because i want all explosives to have a custom preset- now i COULD go to the AudioSource and drag´n drop in the inspector.

But how is this done through scripting?

All i have to go after is the String 'ExplosivesGroup'.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
16
Best Answer

Answer by okkal11 · Apr 22, 2015 at 09:29 PM

This seems to work :)

//First set the mixer that contains the actual group.

 AudioMixer mixer = Resources.Load("MasterMixer") as AudioMixer;

//then we can search for the string like this

 string _OutputMixer = "ExplosivesGroup";        
 GetComponent<AudioSource>().outputAudioMixerGroup = mixer.FindMatchingGroups(_OutputMixer)[0];






Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zero_equals_zero · Nov 24, 2015 at 08:32 AM 0
Share

Thanks This helped me too. However:

Can you also create a audiomixer and child groups? I've searched my way through google and already was happy to find this post.

Cheers

avatar image AlanMattano · Apr 06, 2017 at 03:05 AM 1
Share

Remember to add on top of the C# script the line:

using UnityEngine.Audio;

avatar image ParagonSe7en · Apr 11, 2019 at 11:03 PM 0
Share

This solved my issue, and four years later at that ;). Thanks!

avatar image
1

Answer by Westland · Feb 01, 2019 at 12:15 AM

Alternatively, using singletons, create a public audiomixergroup variable and set it in the Editor Inspector, and set other audiosource's output to that.

Note, this might be bad for reasons I don't know but people keep saying it is, global variables and stuff. But another way of doing it irregardless

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MorphVGX · Mar 24 at 10:13 PM 0
Share

Well, it doesn't need to be a singleton to assign it and use it. So thank you, it still helps.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I get the parent from a AudioMixerGroup Object 2 Answers

Audio help 0 Answers

Listening to Sound Card Output 0 Answers

Second AudioClip won't play 0 Answers

Second AudioClip won't play 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges