示例#1
0
        private void PresentData()
        {
            if (loadingOverlay != null)
            {
                loadingOverlay.SetActive(false);
            }

            if (avatarOverlay != null)
            {
                avatarOverlay.SetActive(m_data.mediaType == ImageDisplayData.MediaType.UserAvatar);
            }
            if (logoOverlay != null)
            {
                logoOverlay.SetActive(m_data.mediaType == ImageDisplayData.MediaType.ModLogo);
            }
            if (galleryImageOverlay != null)
            {
                galleryImageOverlay.SetActive(m_data.mediaType == ImageDisplayData.MediaType.ModGalleryImage);
            }
            if (youTubeOverlay != null)
            {
                youTubeOverlay.SetActive(m_data.mediaType == ImageDisplayData.MediaType.YouTubeThumbnail);
            }

            if (image != null)
            {
                // if original is missing, just use thumbnail
                bool original = m_useOriginal;
                if (original && m_data.GetImageTexture(true) == null)
                {
                    original = false;
                }

                Texture2D texture = m_data.GetImageTexture(original);
                if (texture != null)
                {
                    image.sprite = UIUtilities.CreateSpriteFromTexture(texture);

                    if (fitter != null)
                    {
                        fitter.aspectRatio = ((float)texture.width
                                              / (float)texture.height);
                    }
                    image.enabled = true;
                }
                else
                {
                    image.enabled = false;
                }
            }
        }
示例#2
0
        private void MediaPreview_GalleryImage(ImageDisplayComponent display)
        {
            ImageDisplayData imageData = display.data;

            selectedMediaPreview.data = imageData;

            if (imageData.GetImageTexture(selectedMediaPreview.useOriginal) == null)
            {
                bool original            = selectedMediaPreview.useOriginal;
                ModGalleryImageSize size = (original ? ModGalleryImageSize.Original : ImageDisplayData.galleryThumbnailSize);

                ModManager.GetModGalleryImage(profile, display.data.fileName,
                                              size,
                                              (t) =>
                {
                    if (Application.isPlaying &&
                        selectedMediaPreview.data.Equals(imageData))
                    {
                        imageData.SetImageTexture(original, t);
                        selectedMediaPreview.data = imageData;
                    }
                },
                                              WebRequestError.LogAsWarning);
            }
        }