ProfilerOverlay.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. [RunInEditor]
  19. public sealed class ProfilerOverlay : Component
  20. {
  21. private ProfilerOverlayInternal impl;
  22. /// <summary>
  23. /// Controls whether the overlay is getting updated or not.
  24. /// </summary>
  25. public bool Paused { get; set; }
  26. /// <summary>
  27. /// Changes the type of data displayed by the overlay.
  28. /// </summary>
  29. /// <param name="type">Type that determines the type of data to display.</param>
  30. public void SetType(ProfilerOverlayType type)
  31. {
  32. impl.SetType(type);
  33. }
  34. private void OnReset()
  35. {
  36. if (impl != null)
  37. impl.Destroy();
  38. Camera cam = SceneObject.GetComponent<Camera>();
  39. impl = new ProfilerOverlayInternal(cam);
  40. }
  41. private void Update()
  42. {
  43. if(!Paused)
  44. impl.Update();
  45. }
  46. private void OnDestroy()
  47. {
  48. impl.Destroy();
  49. }
  50. }
  51. }