private void ReloadMaterialList() { // Reset drawPanel.Clear(); materialList = new List <UIButton>(); Main.selectedMaterial = 1; var addEvents = new UIButton(new UIText("Add event", Color.Black), 100, 50, Color.White); addEvents.X.Percent = 25; addEvents.Y.Pixels = 150; addEvents.OnClick += (evt, elm) => { var trigger = new EventTrigger(0, new Rectangle(Point.Zero, new Point(100, 100))); Main.level.EventTriggers.Add(trigger); }; drawPanel.Append(addEvents); var addEnemy = new UIButton(new UIText("Add enemy", Color.Black), 100, 50, Color.White); addEnemy.X.Percent = 75; addEnemy.Y.Pixels = 150; addEnemy.OnClick += (evt, elm) => { var enemy = new Enemy(0, Vector2.Zero); Main.level.Enemies.Add(enemy); }; drawPanel.Append(addEnemy); // Generate Material List int temp = 0; for (int i = 0; i < Main.textureMap.textures.Count; i++) { var btn = new UIButton(new UIText(i, Color.White), 150, 50, Color.DarkGray); temp += 70; btn.X.Percent = 50; btn.Y.Pixels = 150 + temp; btn.OnClick += (evt, elm) => { if (elm is UIButton button && int.TryParse(button.Text.Text, out int result)) { Main.selectedMaterial = result; }