- Home /
Displaying song's name in-game
I'm trying to get the name of a song currently playing in my game to appear on-screen, similar to most of the EA Sports games with their licensed music. Currently, I'm able to use 'audio.clip' in a string to print the information out. However, when I tested it with a song from my iTunes library, the following showed up:
" (UnityEngine.AudioClip)"
I can change the name of the file easily, but I'm not sure where to start when removing the '(UnityEngine.AudioClip)' part. Any direction to the will be helpful.
Answer by Rxanadu · Jan 05, 2013 at 07:58 PM
@ng93: Turns out you were right in using AudioClip.name to project the name of the song. I still have an issue with creating an audio source with my specified audio clip attached to it.
Aside from that, though, you answered my question. Sorry for not viewing this earlier.
Answer by thehiveissocial · Feb 16, 2019 at 11:35 PM
@Rxanadu @ng93 I'm currently trying to do this for a rhythm style game I'm developing. The game has a list of audio stored and when the player changes songs I would like the text to update along with the song. I'm having trouble with the "AudioClip.name," for some reason I can't get it to work unless I'm doing it incorrectly. I have the Text named "songname." In update I called "songname" and tried songname = AudioClips.name, but I can't call name. I'm new to all this and I'm wondering what I'm missing if anyone can help. Thank you in advance! -David
Hello, maybe it can work...
if (audioSource.isPlaying) GameObject.Find("SongName").GetComponent().text = audioSource.clip.name.ToString(); else GameObject.Find("SongName").GetComponent().text = "";
In my case "SongName" is a "TEXT object" and son of "CANVAS". It worked in my Rhythm Game Project.
yeah you need to use Text.text with the text object...