I’m trying to fade in the audioLister over time but i cant seem to get it to work.
public class Opening : MonoBehaviour {
public Transform player;
public GUISkin skin;
public GUISkin skinTwo;
bool closedCapOne = false;
bool closedCapTwo = false;
bool closedCapThree = false;
bool closedCapFour = false;
bool closedCapFive = false;
bool closedCapSix = false;
bool title = true;
float size = 20;
float startT;
float endT;
void Start () {
StartCoroutine(Open());
}
void Update () {
size += 10 * Time.smoothDeltaTime;
}
IEnumerator Open () {
AudioListener.volume = 0.0f;
CameraFade.FadeOutMain(0.1f);
yield return new WaitForSeconds (5);
closedCapOne = true;
title = false;
yield return new WaitForSeconds (8);
closedCapOne = false;
closedCapTwo = true;
yield return new WaitForSeconds (3);
closedCapTwo = false;
closedCapThree = true;
yield return new WaitForSeconds (2);
closedCapThree = false;
closedCapFour = true;
yield return new WaitForSeconds (2);
closedCapFour = false;
closedCapFive = true;
yield return new WaitForSeconds (4);
closedCapFive = false;
closedCapSix = true;
yield return new WaitForSeconds (5);
// fade in sound
startT = Time.time;
endT = Time.time + 2f;
AudioListener.volume = Mathf.Lerp(0.0f, 1.0f, (Time.time - startT) / (endT - startT) );
// --
CameraFade.FadeInMain(3);
yield return new WaitForSeconds (2);
closedCapSix = false;
}
How would you go about this?