using UnityEngine; using UnityEngine.Video; namespace Unity.Tutorials.Core.Editor { /// /// Container class for a type of media used in a TutorialPage. Can be either an image, or a video (clip or url) /// [System.Serializable] public class MediaContent { /// /// The type of Media this define /// public enum MediaContentType { /// /// An Image /// Image, /// /// A Video from a file clip /// VideoClip, /// /// A video from a Url /// VideoUrl } /// /// Which type of source this content media uses /// public MediaContentType ContentType { get => m_ContentType; set => m_ContentType = value; } [SerializeField] private MediaContentType m_ContentType; /// /// The Texture2D used as Image if the Content Type is set to Image /// public Texture2D Image { get => m_Image; set => m_Image = value; } [SerializeField] private Texture2D m_Image; /// /// The Clip used if the source type is set to VideoClip /// public VideoClip VideoClip { get => m_VideoClip; set => m_VideoClip = value; } [SerializeField] private VideoClip m_VideoClip; /// /// The URL to the video if the source type is set to VideoURL /// public string Url { get => m_Url; set => m_Url = value; } [SerializeField] private string m_Url; /// /// If the Content type is video, does it auto start on load, or require the user to press play to start /// public bool AutoStart { get => m_AutoStart; set => m_AutoStart = value; } [SerializeField] private bool m_AutoStart = true; /// /// If the content is video, does it loop when it reaches the end. /// public bool Loop { get => m_Loop; set => m_Loop = value; } [SerializeField] private bool m_Loop = true; /// /// A Media Content is considered valid if the associated media to its set type is not null (e.g. an Image Media /// Content Image properties is not null or a VideoUrl Media url is not null or empty /// /// True if contains the right media, false otherwise public bool IsValid() { return (m_ContentType == MediaContentType.Image && m_Image != null) || (m_ContentType == MediaContentType.VideoClip && m_VideoClip != null) || (m_ContentType == MediaContentType.VideoUrl && !string.IsNullOrEmpty(m_Url)); } } }