I have a problem: in my main menu I want to play random song from Resources folder, but it seems like I’m doing it wrong. Also I have public void “NextTrack()” to play next song. Can someone help me with this problem?
Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class music_main_menu : MonoBehaviour
{
AudioSource audioSource;
// Start is called before the first frame update
void Start()
{
object[] audioList = Resources.FindObjectsOfTypeAll(typeof(AudioClip));
Debug.Log(audioList);
}
public void NextTrack()
{
audioSource.Stop();
audioSource.PlayDelayed(1f);
}
}