Exemplo n.º 1
0
        public void OnPointerEnter(PointerEventData eventData)
        {
            if (!UIAssetsLoader.allPrefabsReady)
            {
                return;
            }

            if (!tooltipPanel)
            {
                tooltipPanel = GameObject.Instantiate(UIAssetsLoader.basicTooltipPrefab);
                tooltipPanel.transform.SetParent(UIMasterController.Instance.appCanvas.transform, false);
                tooltipPanel.GetComponent <CanvasGroup>().alpha          = 0f;
                tooltipPanel.GetComponent <CanvasGroup>().blocksRaycasts = false;

                tooltipPanelFader = tooltipPanel.AddComponent <CanvasGroupFader>();
            }

            var panelRectTransform = tooltipPanel.transform as RectTransform;

            tooltipPanel.GetChild("Text").GetComponent <Text>().text = tooltipText;
            tooltipTime = 0f;

            Vector2 localPointerPosition;

            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(tooltipPanel.transform.parent as RectTransform, eventData.position, eventData.pressEventCamera, out localPointerPosition))
            {
                panelRectTransform.localPosition = localPointerPosition - tooltipOffset;
            }
        }
Exemplo n.º 2
0
 public void DestroyToolTip()
 {
     if (tooltipPanel)
     {
         tooltipPanel.DestroyGameObjectImmediate();
         tooltipPanel      = null;
         tooltipPanelFader = null;
     }
 }