UnityExtendedUtility.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using UnityEngine;
  12. public class UnityExtendedUtility
  13. {
  14. public static RenderTexture CreateRenderTexture(int width, int height, int depth = 24, RenderTextureFormat format = RenderTextureFormat.ARGB32, bool usequaAnti = true)
  15. {
  16. // Fixed UNITY_2018_2 editor preview effect for video capture and photo capture.
  17. #if UNITY_2018_2 && UNITY_EDITOR
  18. var rt = new RenderTexture(width, height, depth, format, NRRenderer.isLinearColorSpace ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.Default);
  19. #else
  20. var rt = new RenderTexture(width, height, depth, format, NRRenderer.isLinearColorSpace ? RenderTextureReadWrite.sRGB : RenderTextureReadWrite.Default);
  21. #endif
  22. rt.wrapMode = TextureWrapMode.Clamp;
  23. if (QualitySettings.antiAliasing > 0 && usequaAnti)
  24. {
  25. rt.antiAliasing = QualitySettings.antiAliasing;
  26. }
  27. rt.Create();
  28. return rt;
  29. }
  30. }
  31. }