I don’t get it.
I had this array that contained two items before, and the indexed array will play the song. It worked just fine.
Now, I want to add more songs to the list. For some reason it wasn’t showing up/playing, so I decided to check the length of the array and turns out, it was the same as before (length was 2 though it should’ve been 3 since I had 3 items in the array).
I decided to see what would happen if I took one of the previous items out and kept the new one in to see if that would play. It didn’t, it somehow kept displaying and playing the old songs- though it’s impossible.
#pragma strict
var songList = ['Au5 - Snowblind','Rameses B - Transformations'];
var background = Texture();
var textMid = GUIText();
var song : AudioClip;
var buttonPress : AudioClip;
private var num = 0;
function OnGui()
{
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), background);
}
function Start()
{
textMid.text = songList[num];
song = Resources.Load('Song Previews/' + songList[num].ToString(), AudioClip);
audio.clip = song;
audio.Play();
}
function Update()
{
if(Input.GetKeyUp(KeyCode.LeftArrow))
{
if(num-1 < 0)
{
num = songList.Length-1;
}
textMid.text = songList[num];
song = Resources.Load('Song Previews/' + songList[num].ToString(), AudioClip);
audio.clip = song;
audio.Play();
Debug.Log(num + " = num, and the length of songlist: " + songList.Length);
}
if(Input.GetKeyUp(KeyCode.RightArrow))
{
if(num+1 == songList.Length)
{
num = 0;
}
textMid.text = songList[num];
song = Resources.Load('Song Previews/' + songList[num].ToString(), AudioClip);
audio.clip = song;
audio.Play();
Debug.Log(num + " = num, and the length of songlist: " + songList.Length);
}
if(Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.Return))
{
//game scene
//Application.LoadLevel(songList[num].ToString());
}
if(Input.GetKeyUp(KeyCode.Escape) || Input.GetKeyUp(KeyCode.Backspace))
{
Application.LoadLevel("MainMenu");
}
}
What currently loads is the first item in the list and a thing that no longer exists in the list instead of what I have as the second item in the list. Even if I add random things in just to see if it’ll pop up on the GUI, it won’t show and the length of the array remains 2.