Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

PerformanceModeVisualisation.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.AdaptivePerformance;
  4. public class PerformanceModeVisualisation : MonoBehaviour
  5. {
  6. public Text performanceModeLabel;
  7. public Image performanceModePanel;
  8. IAdaptivePerformance m_AP;
  9. void OnPerformanceModeEvent(PerformanceMode performanceMode)
  10. {
  11. performanceModeLabel.text = performanceMode.ToString();
  12. switch (performanceMode)
  13. {
  14. case PerformanceMode.Optimize:
  15. case PerformanceMode.CPU:
  16. case PerformanceMode.GPU:
  17. performanceModePanel.color = Color.green;
  18. break;
  19. case PerformanceMode.Unknown:
  20. performanceModePanel.color = Color.magenta;
  21. break;
  22. case PerformanceMode.Standard:
  23. performanceModePanel.color = Color.cyan;
  24. break;
  25. case PerformanceMode.Battery:
  26. performanceModePanel.color = Color.yellow;
  27. break;
  28. }
  29. }
  30. void Start()
  31. {
  32. m_AP = Holder.Instance;
  33. if (m_AP == null)
  34. {
  35. Debug.Log("[Performance Mode Visualization] Warning Adaptive Performance Manager was not found and does not report");
  36. return;
  37. }
  38. m_AP.PerformanceModeStatus.PerformanceModeEvent += OnPerformanceModeEvent;
  39. OnPerformanceModeEvent(m_AP.PerformanceModeStatus.PerformanceMode);
  40. }
  41. }