Esempio n. 1
0
        private void _showPopup(string phraseStart, PopupFacingDir dir, DPCameraOverlay dpParent, RectTransform element)
        {
            //Check to see if the user is still hovering on the same element or not
            if (_potentialPopupElement != element)
            {
                return;
            }

            //Debug.Log(offset);

            _popupShouldBeActive = true;


            title.SetText(LeanLocalization.GetTranslationText(phraseStart + "Title"));
            desc.SetText(LeanLocalization.GetTranslationText(phraseStart + "Desc"));

            title.ForceMeshUpdate();
            desc.ForceMeshUpdate();


            //Canvas.ForceUpdateCanvases();
            LayoutRebuilder.ForceRebuildLayoutImmediate(bg);
            bg.gameObject.SetActive(false);
            bg.gameObject.SetActive(true);

            //transform.parent.GetComponent<VerticalLayoutGroup>().enabled = false;
            //transform.parent.GetComponent<VerticalLayoutGroup>().enabled = true;

            //fitter.enabled = false;
            //fitter.enabled = true;


            //Figure out the right location:
            Vector3 spawnOffset;


            switch (dir)
            {
            case PopupFacingDir.Left:
                spawnOffset            = new Vector3(1, 0, 0);
                arrow.anchoredPosition = new Vector2(-123 - 5, ((bg.rect.height + bg.rect.position.y) / 2) + 5);
                arrow.localEulerAngles = new Vector3(0, 0, -90);

                break;

            default:
            case PopupFacingDir.Down:
                spawnOffset            = new Vector3(0, 0.08f, -0.01f);
                arrow.anchoredPosition = new Vector2(0, 0);
                arrow.localEulerAngles = new Vector3(0, 0, 0);

                break;


            case PopupFacingDir.Right:
                spawnOffset            = new Vector3(-1, 0, 0);
                arrow.anchoredPosition = new Vector2(123, ((bg.rect.height + bg.rect.position.y) / 2) + 5);
                arrow.localEulerAngles = new Vector3(0, 0, 90);

                break;

            case PopupFacingDir.TheBar:
                spawnOffset            = new Vector3(0, 0.1f, 0.06f);
                arrow.anchoredPosition = new Vector2(0, 0);
                arrow.localEulerAngles = new Vector3(0, 0, 0);

                break;
            }


            //Vector3 dpPos = dpParent.transform.position;


            Vector3 goodRot = new Vector3(0, dpParent.transform.eulerAngles.y, 0);


            dpParent.SetOtherTransformRelativeToElement(hoverDP.transform, element, spawnOffset);

            hoverDP.SetOverlayPositionWithCurrent(true, false);


            //hoverDP.SetOverlayPosition(goodPos, goodRot, true, false);
            hoverDP.TransitionOverlayOpacity(1f, 0.5f);


            hoverDP.RequestRendering(true);

            _popupIsActive = true;
        }