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; } } }
/// <summary>Internal function for applying the texture.</summary> protected virtual void ApplyTexture(GalleryImageLocator locator, Texture2D texture) { if (this != null && texture != null && this.m_locator == locator) { this.image.sprite = UIUtilities.CreateSpriteFromTexture(texture); this.image.enabled = true; if (this.onTextureChanged != null) { this.onTextureChanged.Invoke(texture); } } }
/// <summary>Internal function for applying the texture.</summary> protected virtual void ApplyTexture(string youTubeId, Texture2D texture) { if (this != null && texture != null && this.m_youTubeId == youTubeId) { this.image.sprite = UIUtilities.CreateSpriteFromTexture(texture); this.image.enabled = true; if (this.onTextureChanged != null) { this.onTextureChanged.Invoke(texture); } } }
private void DisplayTexture(Texture2D texture) { Debug.Assert(texture != null); if (image != null) { image.sprite = UIUtilities.CreateSpriteFromTexture(texture); if (fitter != null) { fitter.aspectRatio = ((float)texture.width / (float)texture.height); } image.enabled = true; } }