void Start() { AddItem(); template.AddComponent <SongItem>(); for (int i = 0; i < dirCnt; i++) { GameObject obj = Instantiate(template); SongItem sItem = obj.GetComponent <SongItem>(); sItem.songName = newItems[i].songName; sItem.songArtist = newItems[i].songArtist; sItem.songLevel = newItems[i].songLevel; sItem.sprite = newItems[i].sprite; items.Add(obj.GetComponent <SongItem>()); } SongDisplay song = (SongDisplay)Instantiate(songDisplayPrefab); song.Prime(items); }
// Inventory.cs void Start() { SongDisplay song = (SongDisplay)Instantiate(songDisplayPrefab); song.Prime(items); }