- Home /
How do i convert this code snippet to a list?
So i recently found out i need to use lists instead of arrays and have been converting my stuff over, but i ran into a snafu. How can i do my resources.loadall("music") and put it into a list? It worked fine as an array, but i cant seem to find the correct syntax for this.
public List<AudioClip> _songs = new List<AudioClip>();
public List<AudioClip> randomSongs = new List<AudioClip>();
public void Start ()
{
_songs = Resources.LoadAll<AudioClip>("music");
}
Comment
Answer by UnityCoach · May 09, 2017 at 09:28 PM
You can create a new list initialised with the array.
_songs = new List<AudioClip> (Resources.LoadAll<AudioClip>("music"));
Your answer
Follow this Question
Related Questions
Reading all data in the list with duplicate data inside 1 Answer
How to modify array values? 1 Answer
How can I create a tree like list/array structure? 0 Answers
Unity random card select system with persentage 1 Answer
Why the List in the class when using it is not the same in another class ? 1 Answer