ProfilerOverlay.cs 1.7 KB

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