Пример #1
0
 public void SetData(DImagePopup imagePopupData)
 {
     CoroutineRunner.Start(loadImage(imagePopupData.ImageContentKey), this, "loadPopupImage");
     if (DisplayText == null)
     {
         return;
     }
     ImagePanel.anchoredPosition = imagePopupData.ImageOffset;
     ImagePanel.localScale       = new Vector3(imagePopupData.ImageScale.x, imagePopupData.ImageScale.y, 0f);
     if (string.IsNullOrEmpty(imagePopupData.Text))
     {
         DisplayText.gameObject.SetActive(value: false);
         return;
     }
     DisplayText.text     = imagePopupData.Text;
     DisplayText.color    = ColorUtils.HexToColor(imagePopupData.TextStyle.ColorHex);
     DisplayText.fontSize = imagePopupData.TextStyle.FontSize;
     DisplayText.rectTransform.position += new Vector3(imagePopupData.TextOffset.x, imagePopupData.TextOffset.y, 0f);
     if (!string.IsNullOrEmpty(imagePopupData.TextStyle.FontContentKey))
     {
         string fontContentKey = formatFontPath(imagePopupData.TextStyle.FontContentKey);
         CoroutineRunner.Start(loadFont(fontContentKey), this, "ImagePopup.loadFont");
     }
     DisplayText.alignment = imagePopupData.TextAlignment;
 }
        private void onPrefabLoaded(string path, GameObject prefab)
        {
            DImagePopup dImagePopup = new DImagePopup();

            dImagePopup.ImageContentKey = new SpriteContentKey(ImageAssetPath);
            dImagePopup.ImageOffset     = ImageOffset;
            dImagePopup.ImageScale      = ImageScale;
            if (!HasText)
            {
                dImagePopup.Text = "";
            }
            else if (string.IsNullOrEmpty(i18nText))
            {
                dImagePopup.Text = Text;
            }
            else
            {
                dImagePopup.Text = i18nText;
            }
            dImagePopup.TextStyle     = TextStyle;
            dImagePopup.TextAlignment = TextAlignment;
            dImagePopup.TextOffset    = TextOffset;
            popup      = Object.Instantiate(prefab);
            imagePopup = popup.GetComponent <ImagePopup>();
            if (imagePopup != null)
            {
                imagePopup.SetData(dImagePopup);
                imagePopup.EnableCloseButtons(ShowCloseButton, FullScreenClose);
                imagePopup.ShowBackground = ShowBackground;
                imagePopup.OpenDelay      = OpenDelay;
                imagePopup.DoneClose     += onPopupClosed;
            }
            Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(popup));
            if (!WaitForPopupComplete)
            {
                Finish();
            }
        }