Пример #1
0
        private void Initialize()
        {
            if (isInitialized) return;

            RectTransform = gameObject.GetComponent<RectTransform>();

            if (tooltipStyle != null)
            {
                // Check with the TooltipManager to see if there is already a tooltip object instantiated for this style.
                // If there is already a tooltip object in the scene for this style, use it. Otherwise, instantiate it and add it to the TooltipManager.
                if (!TooltipManager.Instance.Tooltips.ContainsKey(tooltipStyle))
                {
                    TooltipStyle ttStyle = Instantiate(tooltipStyle);
                    ttStyle.name = tooltipStyle.name;
                    ttStyle.transform.SetParent(TooltipManager.Instance.RootCanvas.transform, false);
                    Tooltip newTooltip = new Tooltip() { GameObject = ttStyle.gameObject};
                    newTooltip.Initialize();
                    newTooltip.Deactivate();
                    TooltipManager.Instance.Tooltips.Add(tooltipStyle, newTooltip);
                }
                Tooltip = TooltipManager.Instance.Tooltips[tooltipStyle];
            }
            isInitialized = true;
        }