Пример #1
0
    public void OnPointerEnter(PointerEventData data)
    {
        if (itemInfo != null)
        {
            item          = GetComponent <ItemHandleOnGUI>().item;
            itemInfo.item = item;
            itemInfo.ActivateItemInfo();
            if (canvasRectTransform == null)
            {
                return;
            }

            Vector3[] slotCorners = new Vector3[4];
            GetComponent <RectTransform>().GetWorldCorners(slotCorners);
            //Because we set the LeftUp corner as the reference Origin Pivot for ItemInfo RectTransform.
            //So we put the ItemInfo position to the Right Bottom by set ItemInfo's RectTransform to slotCorners[3]
            Vector2 localPointerPosition;
            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, slotCorners[3], data.pressEventCamera, out localPointerPosition))
            {
                itemInfoRectTransform.localPosition = localPointerPosition;
                if (transform.parent.parent.parent.GetComponent <Hotbar>() == null)
                {
                    itemInfoRectTransform.localPosition = localPointerPosition;
                }
                else
                {
                    itemInfoRectTransform.localPosition = new Vector3(localPointerPosition.x, localPointerPosition.y + itemInfo.itemInfoHeight);
                }
            }
        }//end itemInfo != null
    }