ProfilerOverlay.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. namespace BansheeEngine
  4. {
  5. /** @addtogroup Utility
  6. * @{
  7. */
  8. /// <summary>
  9. /// Determines type of data to display on the profiler overlay.
  10. /// </summary>
  11. public enum ProfilerOverlayType // Note: Must match the C++ enum ProfilerOverlayType
  12. {
  13. CPUSamples,
  14. GPUSamples
  15. };
  16. /// <summary>
  17. /// Component that displays a profiler overlay on the main game window.
  18. /// </summary>
  19. [RunInEditor]
  20. public sealed class ProfilerOverlay : ManagedComponent
  21. {
  22. private ProfilerOverlayInternal impl;
  23. /// <summary>
  24. /// Controls whether the overlay is getting updated or not.
  25. /// </summary>
  26. public bool Paused { get; set; }
  27. /// <summary>
  28. /// Changes the type of data displayed by the overlay.
  29. /// </summary>
  30. /// <param name="type">Type that determines the type of data to display.</param>
  31. public void SetType(ProfilerOverlayType type)
  32. {
  33. impl.SetType(type);
  34. }
  35. private void OnReset()
  36. {
  37. if (impl != null)
  38. impl.Destroy();
  39. Camera cam = SceneObject.GetComponent<Camera>();
  40. impl = new ProfilerOverlayInternal(cam);
  41. }
  42. private void OnUpdate()
  43. {
  44. if(!Paused)
  45. impl.Update();
  46. }
  47. private void OnDestroy()
  48. {
  49. impl.Destroy();
  50. }
  51. }
  52. /** @} */
  53. }