Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AudioMixer.SetFloat doesn't work on Awake

Discussion in 'Audio & Video' started by Rodolfo-Rubens, May 6, 2015.

  1. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    380
    You're the best!
     
  2. MelonYoy

    MelonYoy

    Joined:
    Aug 1, 2020
    Posts:
    10
    Still a problem in 2022.3. Very nice!
     
  3. Demexis

    Demexis

    Joined:
    Jul 7, 2021
    Posts:
    16
    It's just crappy design.

    I achieved my goal through temporary queues and subscriptions.

    Imagine you are using a DI-container. Many services, including game objects, have to wait from
    Awake()
    until you register the service responsible for AudioMixer-s in
    Start()
    . It sucks, right?

    A compromise that can be made is to create a wrapper or a separate block of code that queues
    .SetFloat(...)
    requests, and starts executing sequentially when
    Start()
    comes.

    After
    Start()
    , all this code with queues is not needed; it can be bypassed using some flag (
    bool bypassQueues
    ), which is set to true in
    Start()
    .