Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / Sound / Main Menu / MainMenuMusicLoop.cs
@Rackday Rackday on 18 Aug 850 bytes Project Added
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MainMenuMusicLoop : MonoBehaviour
  5. {
  6. public AudioClip[] audioclip;
  7. int currentSong;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. currentSong = 0;
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. if (currentSong <= audioclip.Length)
  17. {
  18. if (gameObject.GetComponent<AudioSource>().isPlaying == false)
  19. {
  20. Debug.Log(currentSong);
  21. gameObject.GetComponent<AudioSource>().clip = audioclip[currentSong];
  22. gameObject.GetComponent<AudioSource>().Play();
  23. currentSong++;
  24. }
  25. }
  26. if (currentSong >= audioclip.Length)
  27. {
  28. currentSong = 0;
  29. }
  30. }
  31. }