public override void Reload(IProperty property) { m_Content.Clear(); m_Elements.Clear(); var set = GetValue(); if (null == set) { return; } foreach (var v in set) { var key = v; var root = new PropertyElement(); m_Elements.Add(root); root.AddToClassList(UssClasses.SetElement.ItemContainer); root.AddToClassList(UssClasses.Variables); root.SetTarget(new SetValue(key)); var element = root[0]; if (null == element) { continue; } VisualElement toRemoveParent; VisualElement contextMenuParent; if (element is Foldout foldout) { foldout.AddToClassList(UssClasses.SetElement.Item); var toggle = foldout.Q <Toggle>(); toggle.AddToClassList(UssClasses.SetElement.ItemFoldout); contextMenuParent = foldout.Q <VisualElement>(className: UssClasses.Unity.ToggleInput); toRemoveParent = toggle; foldout.contentContainer.AddToClassList(UssClasses.SetElement.ItemContent); foldout.contentContainer.SetEnabledSmart(false); } else { toRemoveParent = root; contextMenuParent = root.Q <Label>(); element.AddToClassList(UssClasses.SetElement.ItemNoFoldout); element.contentContainer.SetEnabledSmart(false); root.style.flexDirection = FlexDirection.Row; } contextMenuParent.AddManipulator( new ContextualMenuManipulator(evt => { evt.menu.AppendSeparator(); evt.menu.AppendAction("Delete", action => { OnRemoveItem(key); }); })); var button = new Button(); button.AddToClassList(UssClasses.SetElement.RemoveItemButton); button.clickable.clicked += () => { OnRemoveItem(key); }; toRemoveParent.Add(button); m_Content.Add(root); } }