protected static void DrawListControls <V>(StructureControl <List <V> > control, Div container) { container.Clear(); for (int i = 0; i < control.structure.Count; i++) { int index = i; if (control.specifiedFields.Contains(typeof(V))) { FieldControl <V> fieldControl = new FieldControl <V>(control.structure[index], control.name + "list-item", "item", false, control.world); fieldControl.eventManager.AddListener <FieldControlUpdated <V> >(e => { control.structure[index] = e.control.value; control.eventManager.Raise(new StructureControlUpdated <List <V> >(control)); }); ListItemImage delButton = fieldControl.AddImage(AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/times.png")).AddToClassList("selectable", "hoverable", "icon"); delButton.eventManager.AddListener <MouseClickEvent>(e => { control.structure.RemoveAt(index); control.eventManager.Raise(new StructureControlUpdated <List <V> >(control)); DrawListControls <V>(control, container); }); container.Add(fieldControl); } else { V structure = control.structure[index]; StructureControl <V> structureControl = new StructureControl <V>(ref structure); structureControl.eventManager.AddListener <StructureControlUpdated <V> >(e => { control.eventManager.Raise(new StructureControlUpdated <List <V> >(control)); }); } } }
protected static void DrawSetControls <V>(StructureControl <HashSet <V> > control, Div container) { container.Clear(); foreach (V item in control.structure) { if (control.specifiedFields.Contains(typeof(V))) { FieldControl <V> fieldControl = new FieldControl <V>(item, control.name + "list-item", "item", false, control.world); fieldControl.eventManager.AddListener <FieldControlUpdated <V> >(e => { control.structure.Remove(item); control.structure.Add(e.control.value); control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control)); }); ListItemImage delButton = fieldControl.AddImage(AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/times.png")).AddToClassList("selectable", "hoverable", "icon"); delButton.eventManager.AddListener <MouseClickEvent>(e => { control.structure.Remove(item); control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control)); DrawSetControls <V>(control, container); }); container.Add(fieldControl); } else { V structure = item; StructureControl <V> structureControl = new StructureControl <V>(ref structure); structureControl.eventManager.AddListener <StructureControlUpdated <V> >(e => { control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control)); }); } } }