暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

GetPerformanceLevelsUnit.cs 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #if VISUAL_SCRIPTING_ENABLED
  2. using Unity.VisualScripting;
  3. namespace UnityEngine.AdaptivePerformance.VisualScripting
  4. {
  5. [UnitShortTitle("Get Performance Levels")]
  6. [UnitSubtitle("CPU and GPU Levels")]
  7. [UnitCategory("AdaptivePerformance/Performance")]
  8. public class GetPerformanceLevelsUnit : Unit
  9. {
  10. [DoNotSerialize]
  11. public ValueOutput cpuLevel;
  12. [DoNotSerialize]
  13. public ValueOutput gpuLevel;
  14. int CpuLevel = -1;
  15. int GpuLevel = -1;
  16. protected override void Definition()
  17. {
  18. cpuLevel = ValueOutput<int>("CPU Level", (flow) => { UpdateStats(); return CpuLevel; });
  19. cpuLevel = ValueOutput<int>("GPU Level", (flow) => { UpdateStats(); return GpuLevel; });
  20. }
  21. void UpdateStats()
  22. {
  23. if (Application.isPlaying && Holder.Instance != null)
  24. {
  25. var pm = Holder.Instance.PerformanceStatus.PerformanceMetrics;
  26. CpuLevel = pm.CurrentCpuLevel;
  27. GpuLevel = pm.CurrentGpuLevel;
  28. }
  29. }
  30. }
  31. }
  32. #endif