GUI.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup GUI_Engine
  8. * @{
  9. */
  10. /// <summary>
  11. /// Provides access to a global <see cref="GUIPanel"/> that renders GUI on the main viewport. Use
  12. /// <see cref="GUIWidget"/> if you need more control over the placement of GUI, or require it to be rendered to a
  13. /// different viewport.
  14. /// </summary>
  15. public static class GUI
  16. {
  17. private static GUISkin skin;
  18. private static GUIPanel panel; // Populated by runtime
  19. /// <summary>
  20. /// Skin used for rendering all the GUI elements.
  21. /// </summary>
  22. public static GUISkin Skin
  23. {
  24. get { return skin; }
  25. set
  26. {
  27. skin = value;
  28. IntPtr skinPtr = IntPtr.Zero;
  29. if (value != null)
  30. skinPtr = value.GetCachedPtr();
  31. Internal_SetSkin(skinPtr);
  32. }
  33. }
  34. /// <summary>
  35. /// Container into which all GUI elements should be placed.
  36. /// </summary>
  37. public static GUIPanel Panel
  38. {
  39. get { return panel; }
  40. }
  41. /// <summary>
  42. /// Used by the runtime to set the primary panel.
  43. /// </summary>
  44. /// <param name="panel">Primary panel of the widget.</param>
  45. private static void SetPanel(GUIPanel panel)
  46. {
  47. // We can't set this directly through the field because there is an issue with Mono and static fields
  48. GUI.panel = panel;
  49. }
  50. [MethodImpl(MethodImplOptions.InternalCall)]
  51. private static extern void Internal_SetSkin(IntPtr skin);
  52. }
  53. /** @} */
  54. }