Transition Music from fade in to fade out
So I am trying to transition my menu music to different music when in levels. this should be triggered by a button. Now the function is not appearing at all for the OnClick() button area in Unity. Can someone look at my code and see what i am doing wrong. yes I used animation to do the fade in and out. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour { public Animator musicAnimation; public float waitTime;
public void LoadNextScene()
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex + 1);
}
public void LoadStart()
{
SceneManager.LoadScene(0);
FindObjectOfType<GameStatus>().ResetGame();
}
public void QuitGame()
{
Application.Quit();
}
IEnumerator ChangeScene()
{
musicAnimation.SetTrigger("FadeOut");
yield return new WaitForSeconds(waitTime);
LoadNextScene();
Debug.Log("RUREADY");
}
public void StartButtonMusic()
{
StartCoroutine(ChangeScene());
}
}
Your answer
Follow this Question
Related Questions
Can this browser game be done in Unity? 0 Answers
Can anyone find my mistake? 1 Answer
Animation and sampling frequency in the animation component 0 Answers
Very STrange problem 2 Answers
Audio Issues with Animation + Grounded 0 Answers