2
0

GUI.cs 1.9 KB

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