using System; using System.Collections.Generic; using UnityEngine; namespace UnityEditor.Recorder.Input { /// /// /// Optional base class for image related inputs. /// public abstract class ImageInputSettings : RecorderInputSettings { /// /// Stores the output image width. /// public abstract int OutputWidth { get; set; } /// /// Stores the output image height. /// public abstract int OutputHeight { get; set; } /// /// Indicates if derived classes support transparency. /// public virtual bool SupportsTransparent { get { return true; } } internal bool AllowTransparency; } /// /// /// This class regroups settings required to specify the size of an image input using a size and an aspect ratio. /// [Serializable] public abstract class StandardImageInputSettings : ImageInputSettings { [SerializeField] OutputResolution m_OutputResolution = new OutputResolution(); internal bool forceEvenSize; /// public override int OutputWidth { get { return ForceEvenIfNecessary(m_OutputResolution.GetWidth()); } set { m_OutputResolution.SetWidth(ForceEvenIfNecessary(value)); } } /// public override int OutputHeight { get { return ForceEvenIfNecessary(m_OutputResolution.GetHeight()); } set { m_OutputResolution.SetHeight(ForceEvenIfNecessary(value)); } } internal ImageHeight outputImageHeight { get { return m_OutputResolution.imageHeight; } set { m_OutputResolution.imageHeight = value; } } internal ImageHeight maxSupportedSize { get { return m_OutputResolution.maxSupportedHeight; } set { m_OutputResolution.maxSupportedHeight = value; } } int ForceEvenIfNecessary(int v) { if (forceEvenSize && outputImageHeight != ImageHeight.Custom) return (v + 1) & ~1; return v; } /// protected internal override bool ValidityCheck(List errors) { var ok = true; var h = OutputHeight; if (h > (int) maxSupportedSize) { ok = false; errors.Add("Output size exceeds maximum supported size: " + (int) maxSupportedSize ); } var w = OutputWidth; if (w <= 0 || h <= 0) { ok = false; errors.Add("Invalid output resolution: " + w + "x" + h); } return ok; } } }