///<summary> /// The radio system lets you set 10 stations that will play music automaticly. [you can add station by editing the eAudioM_RadioStation in the 'Enums' script] /// At start, the system will get all musicData in the folder "MusicDatas" and divide them into each station depend on the data you set. /// After, you only need to call if you want to go to next station, previous station or select station and the music will start automaticly, like a real-life radio. ///</summary> #region RADIO Functions ///<summary>Init all the radio station with their music in them</summary> private void InitRadioStation() { //Create the radio player GameObject radio = Instantiate(new GameObject(), transform); radio.AddComponent <AudioSource>(); m_RadioPlayer = radio.GetComponent <AudioSource>(); if (m_RadioPlayer == null) { Debug.LogError(Debug_InitFailed("Can't init the Radio System, Can't create an audioSource for the radio player")); return; } if (m_RadioStationsInput.Count == 0) { Debug.LogError(Debug_InitFailed("There's no RadioData set in the manager, can't use the Radio system!")); return; } //Check the radio stations given by the user for (int i = 0; i < m_RadioStationsInput.Count; i++) { RadioData currentRadio = m_RadioStationsInput[i]; if (currentRadio.HaveMusicInIt()) { m_RadioStations.Add(currentRadio, new RadioStation(currentRadio)); m_RadioStationIds.Add(currentRadio); } else { Debug.LogWarning(Debug_Warning("The radio station: '" + currentRadio.name + "' doesn't have any music in it! Won't be add to the radio system.")); } } m_RadioIsInit = true; m_CurrentRadioId = 0; Debug.Log(Debug_InitSucces("Radio System as been init")); //Initialisation is finish }