Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override void AppendVisualElement(VisualElement ret)
- {
- VisualElement dmgOut = ret.Query<VisualElement>("applyStats");
- ListView damageList = new ListView();
- Func<VisualElement> makeItem = () =>
- {
- //Debug.Log("Make ");
- var box = new VisualElement();
- box.style.flexDirection = FlexDirection.Row;
- box.style.flexGrow = 1f;
- box.style.flexShrink = 0f;
- box.style.flexBasis = 0f;
- box.Add(new Label());
- box.Add(new Button());
- box.Add(new EnumField());
- return box;
- };
- Action<VisualElement, int> bindItem = (e, i) =>
- {
- Debug.Log("Bind for: " + i + " formula count: " + damageOut[i].formula.Count);
- (e.ElementAt(0) as Label).text = i.ToString();
- Button removeBtn = e.ElementAt(1) as Button;
- //int thisIndex = i;
- Action click = () =>
- {
- //Debug.Log("RemoveAt! " + i);
- damageOut.RemoveAt(i);
- damageList.Refresh();
- //Debug.Log(removeBtn..clicked.GetInvocationList().Length);
- //removeBtn.clicked.
- };
- removeBtn.clicked -= click;
- removeBtn.clicked += click;
- removeBtn.text = "-";
- };
- damageList.itemsSource = damageOut;
- damageList.itemHeight = 100;
- damageList.makeItem = makeItem;
- damageList.bindItem = bindItem;
- damageList.style.flexDirection = FlexDirection.Column;
- damageList.style.minHeight = 200;
- damageList.selectionType = SelectionType.Multiple;
- damageList.style.flexGrow = 1f;
- damageList.style.flexShrink = 0f;
- damageList.style.flexBasis = 0f;
- ret.style.flexGrow = 1f;
- dmgOut.style.height = new StyleLength(220);//ret.style.height.value.value + damagePropField.style.height.value.value);
- //dmgOut.contentRect = new Rect(Vector2.zero, new Vector2(100, 100));
- dmgOut.Add(damageList);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement