public override void OnUpdate(float deltaTime) { base.OnUpdate(deltaTime); if (selectedId >= 0) { if (!isDragging && (mouseDownPoint - WMouse.Position).LengthSquared() >= 10f) { isDragging = true; dragging_ghost.GetFirst <TextRenderer>().text = listboxComponent[selectedId]; AddChild(dragging_ghost); } if (isDragging) { dragging_ghost.transform.Position = WMouse.Position + mouseDownOffset; } if (WMouse.LeftMouseClickUp()) { if (isDragging) { OnItemDrop?.Invoke(this, files[selectedId]); RemoveChild(dragging_ghost); } isDragging = false; selectedId = -1; } } }
public void DropItem(int itemIndexToRemove) { //AudioSource.PlayClipAtPoint(items[itemIndexToRemove].dropSFX, Camera.main.transform.position, 0.5f); OnItemDrop?.Invoke(this, new ItemEventArgs() { itemIndex = itemIndexToRemove }); items.RemoveAt(itemIndexToRemove); }
public void DropItem(LootItem itemEntity, Cell cell) { if (!HasItems(cell)) { CreateItemBag(cell); } itemEntity.Drop(cell); OnItemDrop?.Invoke(itemEntity, cell); }
public void OnEndDrag(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) { return; } transform.SetParent(parent); transform.localPosition = iconInitialPos; List <RaycastResult> raycastResults = new List <RaycastResult>(); graphicRaycaster.Raycast(eventData, raycastResults); OnItemDrop?.Invoke(GetComponentInParent <ISlot>(), raycastResults.Select(rr => rr.gameObject).ToList()); }