public override void PerFrameUpdate() { //make item sprite follow cursor if (SelectedItem != null) { Vector3 pos = Input.mousePosition; pos.x = Mathf.Clamp01(pos.x / Screen.width); pos.y = Mathf.Clamp01(pos.y / Screen.height); SelectedItem.Sprite.transform.position = GameManager.Inst.UIManager.UICamera.ViewportToWorldPoint(pos); SelectedItem.Quantity.transform.localPosition = SelectedItem.Sprite.transform.localPosition - new Vector3(SelectedItem.ColumnSize * BackpackGrid.BlockSize / 2f - 4, SelectedItem.RowSize * BackpackGrid.BlockSize / 2f - 4); Vector3 centerPos = SelectedItem.Sprite.transform.localPosition; //find nearest fitting slot for selected item and move the boundary there int fitColumn = 0; int fitRow = 0; List <InventoryGrid> grids = _windowPanel.FindInventoryGrids(); if (FindNearestGridSlot(grids, out fitColumn, out fitRow, SelectedItem.IsPlayerOwned)) { SelectedItem.Boundary.transform.parent = FocusedGrid.transform; if (SelectedItem.Orientation == GridItemOrient.Landscape) { SelectedItem.Boundary.pivot = UIWidget.Pivot.BottomLeft; } else { SelectedItem.Boundary.pivot = UIWidget.Pivot.TopLeft; } SelectedItem.Boundary.transform.localEulerAngles = SelectedItem.Sprite.transform.localEulerAngles; SelectedItem.Boundary.width = SelectedItem.Sprite.width; SelectedItem.Boundary.height = SelectedItem.Sprite.height; SelectedItem.Boundary.transform.localPosition = new Vector3(fitColumn * BackpackGrid.BlockSize, fitRow * BackpackGrid.BlockSize, 0); SelectedItem.Boundary.alpha = 1; SelectedItem.ColumnPos = fitColumn; SelectedItem.RowPos = fitRow; FocusedBodySlot = null; } else { SelectedItem.Boundary.alpha = 0; FocusedBodySlot = null; if (ReplaceItem != null) { ReplaceItem.Sprite.alpha = 1; } } List <BodySlot> bodySlots = _windowPanel.FindBodySlots(); BodySlot fitSlot; if (bodySlots.Count > 0) { if (FindNearestBodySlot(out fitSlot, centerPos, bodySlots, SelectedItem.Item.Type)) { FocusedBodySlot = fitSlot; SelectedItem.Boundary.transform.parent = FocusedBodySlot.transform; SelectedItem.Boundary.pivot = UIWidget.Pivot.Center; SelectedItem.Boundary.transform.localEulerAngles = Vector3.zero; SelectedItem.Boundary.width = FocusedBodySlot.Background.width - 10; SelectedItem.Boundary.height = FocusedBodySlot.Background.height - 10; SelectedItem.Boundary.transform.localPosition = Vector3.zero; SelectedItem.Boundary.alpha = 1; } else { FocusedBodySlot = null; } } List <TempSlot> tempSlots = _windowPanel.FindTempSlots(); TempSlot tempSlot; if (tempSlots.Count > 0) { if (FindNearestTempSlot(out tempSlot, centerPos, tempSlots)) { FocusedTempSlot = tempSlot; SelectedItem.Boundary.transform.parent = FocusedTempSlot.transform; SelectedItem.Boundary.pivot = UIWidget.Pivot.Center; SelectedItem.Boundary.transform.localEulerAngles = Vector3.zero; SelectedItem.Boundary.width = FocusedTempSlot.Background.width - 10; SelectedItem.Boundary.height = FocusedTempSlot.Background.height - 10; SelectedItem.Boundary.transform.localPosition = Vector3.zero; SelectedItem.Boundary.alpha = 1; } else { FocusedTempSlot = null; } } } }