activateTooltip() public method

public activateTooltip ( ) : void
return void
Beispiel #1
0
    public void OnPointerEnter(PointerEventData data)                               //if you hit a item in the slot
    {
        if (tooltip != null)
        {
            if (transform.parent.parent.name == "PlayerGui")
            {
                return;
            }
            item         = GetComponent <ItemOnObject>().item;          //we get the item
            tooltip.item = item;                                        //set the item in the tooltip
            tooltip.activateTooltip();                                  //set all informations of the item in the tooltip
            if (canvasRectTransform == null)
            {
                return;
            }


            Vector3[] slotCorners = new Vector3[4];                      //get the corners of the slot
            GetComponent <RectTransform>().GetWorldCorners(slotCorners); //get the corners of the slot

            Vector2 localPointerPosition;
            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, slotCorners[3], data.pressEventCamera, out localPointerPosition))   // and set the localposition of the tooltip...
            {
                Debug.Log("error Tolltrip " + transform.parent.parent.name);
                if (transform.parent.parent.parent.GetComponent <Hotbar>() == null)
                {
                    tooltipRectTransform.localPosition = localPointerPosition;          //at the right bottom side of the slot
                }
                else
                {
                    tooltipRectTransform.localPosition = new Vector3(localPointerPosition.x, localPointerPosition.y + tooltip.tooltipHeight);
                }
            }
        }
    }
Beispiel #2
0
    void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
    {
        if (tooltip != null)
        {
            item = GetComponent <ItemOnObject>().item;                  //we get the item

            tooltip.item = item;                                        //set the item in the tooltip
            tooltip.activateTooltip();                                  //set all informations of the item in the tooltip

            if (canvasRectTransform == null)
            {
                return;
            }


            Vector3[] slotCorners = new Vector3[4];                      //get the corners of the slot
            GetComponent <RectTransform>().GetWorldCorners(slotCorners); //get the corners of the slot

            Vector2 localPointerPosition;
            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, slotCorners[3], eventData.pressEventCamera, out localPointerPosition))   // and set the localposition of the tooltip...
            {
                if (transform.parent.parent.parent.GetComponent <Hotbar>() == null)
                {
                    tooltipRectTransform.localPosition = localPointerPosition;          //at the right bottom side of the slot
                }
                else
                {
                    tooltipRectTransform.localPosition = new Vector3(localPointerPosition.x, localPointerPosition.y + tooltip.tooltipHeight);
                }
            }
        }
    }
Beispiel #3
0
    public void OnPointerDown(PointerEventData data)
    {
        if (tooltip != null)
        {
            tooltip.tooltipType = TooltipType.Inventory;
            Transform curTransform = this.transform;
            while (curTransform.parent)
            {
                if (curTransform.tag == "MainInventory")
                {
                    tooltip.tooltipType = TooltipType.Inventory;
                    break;
                }
                else if (curTransform.tag == "EquipmentSystem")
                {
                    tooltip.tooltipType = TooltipType.Equipment;
                    break;
                }
                curTransform = curTransform.parent;
            }
            item         = GetComponent <ItemOnObject>().item;          //we get the item
            tooltip.item = item;                                        //set the item in the tooltip
            tooltip.activateTooltip();                                  //set all informations of the item in the tooltip
            if (canvasRectTransform == null)
            {
                return;
            }


            Vector3[] slotCorners = new Vector3[4];                      //get the corners of the slot
            GetComponent <RectTransform>().GetWorldCorners(slotCorners); //get the corners of the slot

            Vector2 localPointerMinPosition;
            Vector2 localPointerMaxPosition;
            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, slotCorners[3], data.pressEventCamera, out localPointerMaxPosition) &&
                RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, slotCorners[1], data.pressEventCamera, out localPointerMinPosition))   // and set the localposition of the tooltip...
            {
                float x = localPointerMaxPosition.x;
                float y = localPointerMinPosition.y;
                if (x + tooltipRectTransform.rect.width > canvasRectTransform.rect.xMax)
                {
                    x = localPointerMinPosition.x - tooltipRectTransform.rect.width;
                }
                if (y - tooltipRectTransform.rect.height < canvasRectTransform.rect.yMin)
                {
                    y += canvasRectTransform.rect.yMin - y + tooltipRectTransform.rect.height;
                }

                tooltipRectTransform.localPosition = new Vector3(x, y);
            }
        }
    }
Beispiel #4
0
    public void OnPointerEnter(PointerEventData data)                               //if you hit a item in the slot
    {
        if (tooltip != null && MouseButton.LeftMouse)
        {
            item         = GetComponent <ItemOnObject>().item;          //we get the item
            tooltip.item = item;                                        //set the item in the tooltip
            tooltip.activateTooltip();                                  //set all informations of the item in the tooltip
            if (canvasRectTransform == null)
            {
                return;
            }


            Vector3[] slotCorners = new Vector3[4];                      //get the corners of the slot
            GetComponent <RectTransform>().GetWorldCorners(slotCorners); //get the corners of the slot

            Vector2 localPointerPosition;
        }
    }