Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
5
Question by Piflik · Mar 27, 2015 at 10:40 AM · audioawake

AudioMixer and Awake

I have encountered a courious behaviour with the AudioMixer. I want to change the Volumes of my Sounds on startup to match the ones saved the last time the game was running, so I put a function in an Awake() to read a float from PlayerPrefs and use that in the AudioMixer. But this does not work. There is no exception thrown, but AudioMixer.SetFloat() doesn't seem to have an effect in Awake(). The same code works fine in Start().

Is this a desired or anticipated behaviour, and I just don't see the reason or explanation?

(Side Note: AudioMixer.GetFloat() does work in Awake(), but it returns the value set vie the Audio Mixer tab in the Editor)

Comment
Add comment · Show 7
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 Ewanuk · Apr 16, 2015 at 02:47 PM 0
Share

Having the same issue.

avatar image WoozyBytes · Apr 16, 2015 at 05:04 PM 0
Share

Is there a reason why you don't want to do that in the Start() function ??

I always do it in Start() when i try to do stuff like that on Awake i also get strange results so is not even an option for me .
avatar image $$anonymous$$ · Apr 26, 2015 at 05:04 PM 0
Share

Just to add to this, having the same issue. $$anonymous$$ade a test script to reassign the floats on a button press, and it works once the scene is initialized, nothing else works on Awake.

avatar image tjunqueira · Jul 09, 2016 at 02:40 PM 1
Share

Same problem here. It seems that the SetFloat is not ready to be used, although unity don't even show a error or warning message at the console.

avatar image oferei · Oct 05, 2016 at 02:43 PM 0
Share

Same Here: SetFloat doesn't work in Awake, but works in Start. Sounds like a bug to me.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Rabadash8820 · Jan 12, 2020 at 06:05 AM

I know its like 5 years later, but I was just grappling with this issue myself in 2019.2. Looks like, oddly enough, this is intended behavior. I.e., getting AudioMixer parameters in Awake is fine, but setting them is undefined behavior.

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 michaelday008 · Aug 24, 2021 at 06:52 PM 0
Share

Thanks for posting that. 5 years later they still haven't fixed their documentation so we still have to rely on a bug report from a rather unknown unity subdomain to let us know that this is undocumented, confusing, but "intended" behavior by the developers, who haven't seen fit to officially enlighten us on the SetFloat() page... I wasted 5 hours trying to debug this before finally finding the right combination of google keywords to search and come up with this post!

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

28 People are following this question.

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

Related Questions

Using OnAudioFilterRead with playOnAwake 0 Answers

How to add audio source to gameobject with PlayOnAwake turn on through script? 1 Answer

Strange Audio Output During Awake() 0 Answers

Unity Sound Quality Problem 0 Answers

Audio wont play/stop in standalone mode, but works in editor 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