Hey guys, I am trying to get help learning how to customise my GUI. I am using GUI Layout but if someone could show me how to do this using normal GUI it would be a lot better for me. Anyway, what I am trying to do is that if the list of KFI is bigger than 5, the top one gets removed from screen and the bottom one gets added. Anybody know how to do that? This would really help me get more into GUI in Unity. Here is the script I am using:
public List<KillFeedInfo> KFI = new List<KillFeedInfo>();
public static KillFeed Instance;
// Use this for initialization
void Start () {
Instance = this;
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
GUILayout.BeginArea(new Rect(Screen.width - 300, 0, 200, 200));
foreach (KillFeedInfo k in KFI)
{
GUILayout.BeginHorizontal();
GUILayout.Label(k.Killer);
GUILayout.Label("[" + k.Gun + "]");
GUILayout.Label(k.Killed);
GUILayout.EndHorizontal();
}
GUILayout.EndArea();
}
}
[System.SerializableAttribute]
public class KillFeedInfo
{
public string Killer;
public string Gun;
public string Killed;
}
I would appreciate any help, thanks in advance.