123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace UnityEditor.Recorder.Input
- {
-
-
-
-
- public abstract class ImageInputSettings : RecorderInputSettings
- {
-
-
-
- public abstract int OutputWidth { get; set; }
-
-
-
- public abstract int OutputHeight { get; set; }
-
-
-
- public virtual bool SupportsTransparent
- {
- get { return true; }
- }
- internal bool AllowTransparency;
- }
-
-
-
-
- [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<string> 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;
- }
- }
- }
|