ProfilerOverlay.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace BansheeEngine
  6. {
  7. /// <summary>
  8. /// Determines type of data to display on the profiler overlay.
  9. /// </summary>
  10. public enum ProfilerOverlayType // Note: Must match the C++ enum ProfilerOverlayType
  11. {
  12. CPUSamples,
  13. GPUSamples
  14. };
  15. /// <summary>
  16. /// Component that displays a profiler overlay on the main game window.
  17. /// </summary>
  18. public class ProfilerOverlay : Component
  19. {
  20. private ProfilerOverlayInternal impl;
  21. /// <summary>
  22. /// Controls whether the overlay is getting updated or not.
  23. /// </summary>
  24. public bool Paused { get; set; }
  25. /// <summary>
  26. /// Changes the type of data displayed by the overlay.
  27. /// </summary>
  28. /// <param name="type">Type that determines the type of data to display.</param>
  29. public void SetType(ProfilerOverlayType type)
  30. {
  31. impl.SetType(type);
  32. }
  33. private void OnReset()
  34. {
  35. if (impl != null)
  36. impl.Destroy();
  37. Camera cam = SceneObject.GetComponent<Camera>();
  38. impl = new ProfilerOverlayInternal(cam);
  39. }
  40. private void Update()
  41. {
  42. if(!Paused)
  43. impl.Update();
  44. }
  45. private void OnDestroy()
  46. {
  47. impl.Destroy();
  48. }
  49. }
  50. }