OutputResolution.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using UnityEditor.Recorder.Input;
  3. using UnityEngine;
  4. namespace UnityEditor.Recorder
  5. {
  6. [Serializable]
  7. class OutputResolution
  8. {
  9. [SerializeField] int m_CustomWidth = 1024;
  10. [SerializeField] int m_CustomHeight = 1024;
  11. [SerializeField] internal ImageHeight imageHeight = ImageHeight.x720p_HD;
  12. [SerializeField] internal ImageHeight maxSupportedHeight = ImageHeight.x4320p_8K;
  13. [SerializeField] AspectRatio m_AspectRatio = new AspectRatio();
  14. public int GetWidth()
  15. {
  16. if (imageHeight == ImageHeight.Custom)
  17. return m_CustomWidth;
  18. if (imageHeight == ImageHeight.Window)
  19. {
  20. int w, h;
  21. GameViewSize.GetGameRenderSize(out w, out h);
  22. return w;
  23. }
  24. var aspect = m_AspectRatio.GetAspect();
  25. return (int) (aspect * (int)imageHeight);
  26. }
  27. public int GetHeight()
  28. {
  29. if (imageHeight == ImageHeight.Custom)
  30. return m_CustomHeight;
  31. if (imageHeight == ImageHeight.Window)
  32. {
  33. int w, h;
  34. GameViewSize.GetGameRenderSize(out w, out h);
  35. return h;
  36. }
  37. return (int)imageHeight;
  38. }
  39. public void SetWidth(int w)
  40. {
  41. imageHeight = ImageHeight.Custom;
  42. m_CustomWidth = w;
  43. }
  44. public void SetHeight(int h)
  45. {
  46. imageHeight = ImageHeight.Custom;
  47. m_CustomHeight = h;
  48. }
  49. }
  50. }