Ok in my previous question i found out how to use lists and after reading the documentation on them id like to find out how to display them in a label inside on unity
here is what i have so far if its not to much bother to read through
id also like to know how to sort it
Creating the list
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class NextLevel : MonoBehaviour {
public int LevelName;
public bool ResetTime;
// Use this for initialization
public List<int> iList = new List<int>();
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "NextLevel")
{
Application.LoadLevel (LevelName);
if (ResetTime == true)
{
iList.Add(PlayerPrefs.GetInt("Time"));
PlayerPrefs.SetInt("Time", 0);
}
}
}
}
And in a seperate script in the main menu id like it to display it
using UnityEngine;
using System.Collections;
public class HighScore : MonoBehaviour {
NextLevel s1;
IEnumerator Start()
{
s1 = GetComponent<NextLevel>();
yield return new WaitForEndOfFrame();
foreach(int i in s1.iList)
print (i);
}
}
but i cant find a good way to display it in a label