I have a dynamic dropdown list that adds and refreshes its entries. I can add items just fine, but I can’t get rid of them! My dropdown list is a list of connected P2P clients for some net code testing in Unity. So every time there is a connect or disconnect, this needs to update.
This is my update code
public void UpdateClientListUI () {
// DD_ClientList.ClearOptions();
// DD_ClientList.options = new List<Dropdown.OptionData>();
// DD_ClientList.RefreshShownValue();
// DD_ClientList.value = 1;
// DD_ClientList.value = 0;
// foreach (var op in DD_ClientList.options) {
// DD_ClientList.options.Remove(op);
// }
var opList = new List<Dropdown.OptionData>();
foreach (var client in Command.clients) {
var op = new Dropdown.OptionData();
op.text = client.name + " - " + client.uuid;
opList.Add(op);
}
DD_ClientList.AddOptions(opList);
}
The commented-out code at the top is everything I’ve tried to clear the whole list, and it doesn’t work. I keep getting duplicate entries. I just have no idea how this should work.