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);
}
}
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);
}
}
}