GUI.cs 1.7 KB

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