internal static (MusicLoadResult, AudioClip) AddMusic(string trackName, AudioType formatType, string filePath) { if (!IsTrackNameAvailable(trackName)) { return(MusicLoadResult.DuplicateTrackName, null); } var trackConfig = new TrackConfig { audioType = formatType, filePath = filePath }; if (!File.Exists(trackConfig.GetAbsolutePath())) { return(MusicLoadResult.FileNotFound, null); } AudioClip clip = TrackLoadingUtils.LoadMusicTrackNow(trackConfig); return(clip == null ? (MusicLoadResult.UnknownError, null) : (MusicLoadResult.Success, clip)); }
internal static IEnumerator AddMusicAsync(string trackName, AudioType formatType, string filePath, Action <MusicLoadResult, AudioClip> callback = null) { if (!IsTrackNameAvailable(trackName)) { callback?.Invoke(MusicLoadResult.DuplicateTrackName, null); yield break; } var trackConfig = new TrackConfig { audioType = formatType, filePath = filePath }; if (!File.Exists(trackConfig.GetAbsolutePath())) { callback?.Invoke(MusicLoadResult.FileNotFound, null); yield break; } yield return(TrackLoadingUtils.LoadMusicTrack(trackConfig, clip => { callback?.Invoke(clip == null ? MusicLoadResult.UnknownError : MusicLoadResult.Success, clip); })); }