public void AddItem(UIItem item, Vector2 position) { base.AddItem(item); item.SetValid(true); item.transform.SetParent(transform); item.AnchoredPosition = position; _items.Add(item); Vector2Int index = GetIndexForPosition(position); FillSlots(index.x, index.y, item.GetDimensions().x, item.GetDimensions().y, true); }
private void RemoveItem(UIItem item) { if (!_items.Contains(item)) { return; } Vector2Int pos = GetIndexForPosition(item.AnchoredPosition); FillSlots(pos.x, pos.y, item.GetDimensions().x, item.GetDimensions().y, false); _items.Remove(item); item.SetDragged(true); item.transform.SetParent(item.transform.parent.parent); }
public override void AddItem(UIItem item) { if (item == null) { return; } base.AddItem(item); bool isDragging = item.Dragging; item.SetDragged(false); item.SetValid(true); item.transform.SetParent(transform); _items.Add(item); item.GetRectTransform().anchoredPosition = CalculatePosition(item.GetRectTransform().anchoredPosition); Vector2Int index = GetIndexForPosition(item.GetRectTransform().anchoredPosition); FillSlots(index.x, index.y, item.GetDimensions().x, item.GetDimensions().y, true); }