EffectEvlaData.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #if UNITY_EDITOR
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. /// <summary>
  7. /// 处理像素计算
  8. /// </summary>
  9. public class EffectEvlaData
  10. {
  11. public int pixDrawTimes = 0; // 总调用的渲染次数
  12. public int pixTotal = 0; // n次后的理论上总渲染数
  13. public int pixActualDrawTotal = 0; // n次后的实际上渲染次数
  14. public string quality;
  15. //获取指定区域内的所有像素
  16. public int GetPixDrawAverage()
  17. {
  18. if (pixDrawTimes == 0)
  19. {
  20. return 0;
  21. }
  22. return pixTotal / pixDrawTimes;
  23. }
  24. //获取指定区域内的实际每个像素的绘制总数
  25. public int GetPixActualDrawAverage()
  26. {
  27. if (pixDrawTimes == 0)
  28. {
  29. return 0;
  30. }
  31. return pixActualDrawTotal / pixDrawTimes;
  32. }
  33. //平均像素绘制次数
  34. public int GetPixRate()
  35. {
  36. int pixDrawAverage = GetPixDrawAverage();
  37. if (pixDrawAverage == 0)
  38. {
  39. return 0;
  40. }
  41. //实际总绘制次数 / 总像素点
  42. return GetPixActualDrawAverage() / GetPixDrawAverage();
  43. }
  44. public string GetPixDrawAverageStr()
  45. {
  46. return "特效原填充像素点:" + this.GetPixDrawAverage();
  47. }
  48. public string GetPixActualDrawAverageStr()
  49. {
  50. return "特效实际填充像素点:" + this.GetPixActualDrawAverage();
  51. }
  52. public string GetPixRateStr()
  53. {
  54. return "平均每像素overdraw率:" + this.GetPixRate();
  55. }
  56. }
  57. #endif