No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SetPerformanceLevelsUnit.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #if VISUAL_SCRIPTING_ENABLED
  2. using System;
  3. using Unity.VisualScripting;
  4. namespace UnityEngine.AdaptivePerformance.VisualScripting
  5. {
  6. [UnitShortTitle("Set Performance Level")]
  7. [UnitSubtitle("CPU and GPU Levels")]
  8. [UnitCategory("AdaptivePerformance/Performance")]
  9. public class SetPerformanceLevelsUnit : Unit
  10. {
  11. [DoNotSerialize]
  12. public ControlInput inputTrigger;
  13. [DoNotSerialize]
  14. public ControlOutput outputTrigger;
  15. [DoNotSerialize]
  16. public ValueInput cpuLevelInput;
  17. [DoNotSerialize]
  18. public ValueInput gpuLevelInput;
  19. protected override void Definition()
  20. {
  21. inputTrigger = ControlInput("inputTrigger", (flow) =>
  22. {
  23. if (Application.isPlaying && Holder.Instance != null)
  24. {
  25. var pc = Holder.Instance.DevicePerformanceControl;
  26. var cpuInput = flow.GetValue<int>(cpuLevelInput);
  27. var gpuInput = flow.GetValue<int>(gpuLevelInput);
  28. if (cpuInput >= 0)
  29. {
  30. pc.CpuLevel = cpuInput;
  31. }
  32. if (gpuInput >= 0)
  33. {
  34. pc.GpuLevel = gpuInput;
  35. }
  36. }
  37. return outputTrigger;
  38. });
  39. outputTrigger = ControlOutput("outputTrigger");
  40. cpuLevelInput = ValueInput<int>("CPU Level", -1);
  41. gpuLevelInput = ValueInput<int>("GPU Level", -1);
  42. }
  43. }
  44. }
  45. #endif