private bool onShowTooltip(TutorialUIEvents.ShowTooltip evt)
        {
            TutorialTooltip component = evt.Tooltip.GetComponent <TutorialTooltip>();

            showTooltip(component, evt.Target, evt.Offset, evt.FullScreenClose);
            return(false);
        }
示例#2
0
        private bool onTooltipCreated(TutorialUIEvents.OnTooltipCreated evt)
        {
            TutorialTooltip tooltip = evt.Tooltip;

            tooltip.ClearAllText();
            for (int i = 0; i < TextStrings.Length; i++)
            {
                tooltip.AddText(TextStrings[i], ColorUtils.HexToColor(TextStyles[i].ColorHex), TextStyles[i].FontSize);
            }
            Service.Get <EventDispatcher>().RemoveListener <TutorialUIEvents.OnTooltipCreated>(onTooltipCreated);
            Finish();
            return(false);
        }
        private GameObject showTooltip(TutorialTooltip tooltip, RectTransform target, Vector2 offset, bool fullScreenClose)
        {
            if (currentTooltip != null)
            {
                currentTooltip.GetComponent <TutorialTooltip>().Hide();
            }
            Vector2 vector = Vector2.zero;

            if (target != null)
            {
                vector = new Vector2(target.position.x, target.position.y);
                Canvas componentInParent = target.GetComponentInParent <Canvas>();
                if (componentInParent.renderMode == RenderMode.ScreenSpaceCamera)
                {
                    vector = RectTransformUtility.WorldToScreenPoint(componentInParent.worldCamera, vector);
                }
            }
            CanvasScalerExt component = GetComponentInParent <Canvas>().GetComponent <CanvasScalerExt>();
            Vector2         vector2   = new Vector2(component.ReferenceResolutionY / (float)Screen.height, component.ReferenceResolutionY / (float)Screen.height);

            vector2 *= 1f / component.ScaleModifier;
            vector   = new Vector2((vector.x + offset.x) * vector2.x, (vector.y + offset.y) * vector2.y);
            if (tooltip == null)
            {
                GameObject gameObject = Object.Instantiate(tooltipPrefab);
                tooltip = gameObject.GetComponent <TutorialTooltip>();
            }
            tooltip.transform.SetParent(base.transform, worldPositionStays: false);
            tooltip.SetPosition(vector);
            tooltip.SetDefaultTextPrefab(defaultTextPrefab);
            tooltip.Show();
            currentTooltip = tooltip.gameObject;
            FullScreenButton.SetActive(fullScreenClose);
            Service.Get <EventDispatcher>().DispatchEvent(new TutorialUIEvents.OnTooltipCreated(tooltip));
            return(tooltip.gameObject);
        }
 public OnTooltipCreated(TutorialTooltip tooltip)
 {
     Tooltip = tooltip;
 }