ProfilerOverlay.cs 1.6 KB

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