Help with GUILayout

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.

It should be something like this:

...
    void OnGUI()
    {
		int row = 0;
		int rowHeight = 30;
		foreach (KillFeedInfo k in KFI)
		{
			GUI.Label(new Rect(Screen.width - 300, 0 + row * rowHeight, 200, 200), k.Killer);
			GUI.Label(new Rect(Screen.width - 200, 0 + row * rowHeight, 200, 200), "[" + k.Gun + "]");
			GUI.Label(new Rect(Screen.width - 100, 0 + row * rowHeight, 200, 200), k.Killed);
			row++;
		}
    }
...

(Tip) You can still use the GUILayout.BeginArea with regular gui inside it or you can change it to GUI.BeginGroup.

Thanks very much, I managed to get it to work with help of some other code and your method! :slight_smile: