I am having a difficult time with coding where I can change the music(using animation to fade in and fade out the music).
My code is this currently
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());
}
}
/////
I know it is not even passing into ChangeScene from my debug.Log and it tells me for the StartCoroutine(ChangeScene()) that Scene Loader is inactive, but how would I even activate it? And how can it be inactive if I can change scenes just fine?