Example #1
0
        public void OnPointerEnter(PointerEventData eventData)
        {
            if (string.IsNullOrEmpty(text))
            {
                Tooltip.Close();
                return;
            }

            var model = TextTooltipViewModel.instance;

            model.text  = text;
            currentText = text;

            TooltipAnchorTarget target;

            if (this.anchorToMouse)
            {
                target = TooltipAnchorTarget.ForMouse(this.followMouse);
            }
            else if (this.transform is RectTransform)
            {
                target = TooltipAnchorTarget.ForUIObject(this.transform as RectTransform, this.tooltipPivotInRectTransform);
            }
            else
            {
                target = TooltipAnchorTarget.ForWorldObject(this.transform);
            }

            Tooltip.Open(model, target);
            pointerInside = true;
        }
Example #2
0
        /// <summary>
        /// Opens the tooltip with the specified view model and anchor.
        /// If there is no tooltip instance it will output a warning, unless unity is running in headless mode.
        /// </summary>
        public static void Open <T>(T model, TooltipAnchorTarget anchor = default(TooltipAnchorTarget)) where T : TooltipViewModel
        {
            if (ReferenceEquals(instance, null))
            {
                if (!Essentials.IsRunningHeadless())                 // Servers and other headless apps dont care about tooltips
                {
                    Debug.LogWarning("Tried opening tooltip with no tooltip in the scene!");
                }
                return;
            }

            instance._Open(model, anchor);
        }
Example #3
0
        /// <summary>
        /// <see cref="Open{T}(T, TooltipAnchorTarget)"/>
        /// </summary>
        private void _Open <T>(T model, TooltipAnchorTarget anchor) where T : TooltipViewModel
        {
            _Close();
            if (!ReferenceEquals(this.currentContent, null))
            {
                this.currentContent.gameObject.SetActive(false);
            }

            currentContent = GetContentPrefabInstance(model.prefab);
            currentContent.gameObject.SetActive(true);
            currentContent.target = model;
            currentContent.UpdateBinding();
            this.anchor = anchor;
            UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform as RectTransform);
        }
Example #4
0
        public void OnPointerEnter(PointerEventData eventData)
        {
            var model = TextTooltipViewModel.instance;

            model.text = text;

            TooltipAnchorTarget target;

            if (this.anchorToMouse)
            {
                target = TooltipAnchorTarget.ForMouse(this.followMouse);
            }
            else if (this.transform is RectTransform)
            {
                target = TooltipAnchorTarget.ForUIObject(this.transform as RectTransform, this.tooltipPivotInRectTransform);
            }
            else
            {
                target = TooltipAnchorTarget.ForWorldObject(this.transform);
            }

            Tooltip.Open(model, target);
        }