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.

OnBoostUnit.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if VISUAL_SCRIPTING_ENABLED
  2. using Unity.VisualScripting;
  3. namespace UnityEngine.AdaptivePerformance.VisualScripting
  4. {
  5. [UnitShortTitle("On CPU/GPU Boosted")]
  6. [UnitSubtitle("CPU and GPU Boost Event")]
  7. [UnitCategory("AdaptivePerformance/Performance")]
  8. public class OnBoostUnit : EventUnit<PerformanceBoostChangeEventArgs>
  9. {
  10. [DoNotSerialize]
  11. public ValueOutput cpuBoost;
  12. [DoNotSerialize]
  13. public ValueOutput gpuBoost;
  14. bool CpuBoost = false;
  15. bool GpuBoost = false;
  16. protected override bool register => true;
  17. public override EventHook GetHook(GraphReference reference)
  18. {
  19. return new EventHook(AdaptivePerformanceEventHooks.OnBoostEvent);
  20. }
  21. protected override void AssignArguments(Flow flow, PerformanceBoostChangeEventArgs data)
  22. {
  23. flow.SetValue(cpuBoost, data.CpuBoost);
  24. flow.SetValue(gpuBoost, data.GpuBoost);
  25. }
  26. protected override void Definition()
  27. {
  28. base.Definition();
  29. cpuBoost = ValueOutput<bool>("CPU Boost", (flow) => { UpdateStats(); return CpuBoost; });
  30. gpuBoost = ValueOutput<bool>("GPU Boost", (flow) => { UpdateStats(); return GpuBoost; });
  31. }
  32. void UpdateStats()
  33. {
  34. if (Application.isPlaying && Holder.Instance != null)
  35. {
  36. var pm = Holder.Instance.PerformanceStatus.PerformanceMetrics;
  37. CpuBoost = pm.CpuPerformanceBoost;
  38. GpuBoost = pm.GpuPerformanceBoost;
  39. }
  40. }
  41. }
  42. }
  43. #endif