Esempio n. 1
0
        private static void AddPrivate(Rect rect, string tip, TooltipLocation defaultLocation)
        {
            if (rect.Contains(Event.current.mousePosition))
            {
                currentTip = new Tooltip {rect = rect, tooltip = (tip??"")};
                var content = new GUIContent(currentTip.tooltip);
                var height = defaultStyle.CalcHeight(content, MaxWidth);
                float minWidth, maxWidth;
                defaultStyle.CalcMinMaxWidth(content, out minWidth, out maxWidth);
                currentTip.size = new Vector2(Mathf.Min(MaxWidth, maxWidth+2f), height);
                currentTip.screenRect = GUIToScreenRect(rect);

                Open(new Rect(rect.position - new Vector2(0, 6), rect.size + new Vector2(0, 12)), currentTip, defaultLocation);

            }
            else if (currentTip != null)
            {
                var localRect = ScreenToGUIRect(currentTip.screenRect);
                if (!localRect.Contains(Event.current.mousePosition))
                {
                    TooltipServiceWindow.Hide();
                    currentTip = null;
                }
            }
        }
Esempio n. 2
0
        private static void Open(Rect rect, Tooltip window, TooltipLocation defaultLocation)
        {
            var locationPriorityOrder = new[]
            {
                defaultLocation,
                TooltipLocation.Below,
                TooltipLocation.Above,
                TooltipLocation.Right,
                TooltipLocation.Left
            };

            TooltipServiceWindow.Show(rect, window, locationPriorityOrder);
        }