Açıklama Yok
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.

GetThermalMetricUnit.cs 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #if VISUAL_SCRIPTING_ENABLED
  2. using System;
  3. using Unity.VisualScripting;
  4. namespace UnityEngine.AdaptivePerformance.VisualScripting
  5. {
  6. [UnitShortTitle("Thermal Metric")]
  7. [UnitSubtitle("Throttling and Thermal Info")]
  8. [UnitCategory("AdaptivePerformance/Thermal")]
  9. public class GetThermalMetricUnit : Unit
  10. {
  11. [DoNotSerialize]
  12. public ValueOutput warningLevel { get; private set; }
  13. [DoNotSerialize]
  14. public ValueOutput throttlingImminent;
  15. [DoNotSerialize]
  16. public ValueOutput throttling;
  17. [DoNotSerialize]
  18. public ValueOutput temperatureLevel;
  19. [DoNotSerialize]
  20. public ValueOutput temperatureTrend;
  21. float TemperatureLevel = -1.0f;
  22. float TemperatureTrend = -1.0f;
  23. string WarningLevel = "unknown";
  24. bool ThrottlingImminent = false;
  25. bool Throttling = false;
  26. protected override void Definition()
  27. {
  28. warningLevel = ValueOutput<String>(nameof(warningLevel), (flow) => { UpdateStats(); return WarningLevel; });
  29. throttlingImminent = ValueOutput<bool>("throttlingImminent", (flow) => { UpdateStats(); return ThrottlingImminent; });
  30. throttling = ValueOutput<bool>("throttling", (flow) => { UpdateStats(); return Throttling; });
  31. temperatureLevel = ValueOutput<float>("Temperature Level", (flow) => { UpdateStats(); return TemperatureLevel; });
  32. temperatureTrend = ValueOutput<float>("Temperature Trend", (flow) => { UpdateStats(); return TemperatureTrend; });
  33. }
  34. void UpdateStats()
  35. {
  36. if (Application.isPlaying && Holder.Instance != null)
  37. {
  38. var tm = Holder.Instance.ThermalStatus.ThermalMetrics;
  39. TemperatureLevel = tm.TemperatureLevel;
  40. TemperatureTrend = tm.TemperatureTrend;
  41. ThrottlingImminent = tm.WarningLevel == AdaptivePerformance.WarningLevel.ThrottlingImminent;
  42. Throttling = tm.WarningLevel == AdaptivePerformance.WarningLevel.Throttling;
  43. WarningLevel = tm.WarningLevel.ToString();
  44. }
  45. }
  46. }
  47. }
  48. #endif