- Home /
 
               Question by 
               Joe-Kataldo · Jan 05, 2017 at 08:23 AM · 
                c#audiomixingsnapshot  
              
 
              Audio Snapshot TransitionTo Not Working in Awake and Start
Is there any reason why this doesn't work? I think it might be a BUG.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Audio;
 
 public class JKDefaultSnapshot : MonoBehaviour
 {
 
     public List<AudioMixerSnapshot> snapshots;
     public float transitionTime;
 
     void Awake ()
     {
         foreach(var snapshot in snapshots)
             snapshot.TransitionTo(transitionTime);
     }
 }
               Comment
              
 
               
              Answer by glitchers · May 19, 2017 at 10:39 AM
I got around this issue by calling the transition a frame later. Start a coroutine in your awake, wait a frame then fade in. Here is how your script would look.
     using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     using UnityEngine.Audio;
 
     public class JKDefaultSnapshot : MonoBehaviour
     {
         public List<AudioMixerSnapshot> snapshots;
         public float transitionTime;
 
         void Awake ()
         {
             StartCoroutine( TransitionToSnapshots() );
         }
 
         private IEnumerator TransitionToSnapshots()
         {
             // we wait for 1 frame then fade in, and then it works.
             yield return null;
 
             foreach(var snapshot in snapshots)
             {
                 snapshot.TransitionTo(transitionTime);
             }
         }
     }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                