GUILabel.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /// GUI element that displays text.
  9. /// </summary>
  10. public sealed class GUILabel : GUIElement
  11. {
  12. /// <summary>
  13. /// Creates a new label element.
  14. /// </summary>
  15. /// <param name="content">Content to display on the label.</param>
  16. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  17. /// default layout options. Style will be retrieved from the active GUISkin. If not specified
  18. /// default element style is used.</param>
  19. /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
  20. /// override any similar options set by style.</param>
  21. public GUILabel(GUIContent content, string style, params GUIOption[] options)
  22. {
  23. Internal_CreateInstance(this, content, style, options);
  24. }
  25. /// <summary>
  26. /// Creates a new label element.
  27. /// </summary>
  28. /// <param name="content">Content to display on the label.</param>
  29. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  30. /// default layout options. Style will be retrieved from the active GUISkin. If not specified
  31. /// default element style is used.</param>
  32. public GUILabel(GUIContent content, string style = "")
  33. {
  34. Internal_CreateInstance(this, content, style, new GUIOption[0]);
  35. }
  36. /// <summary>
  37. /// Creates a new label element.
  38. /// </summary>
  39. /// <param name="content">Content to display on the label.</param>
  40. /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
  41. /// override any similar options set by style.</param>
  42. public GUILabel(GUIContent content, params GUIOption[] options)
  43. {
  44. Internal_CreateInstance(this, content, "", options);
  45. }
  46. /// <summary>
  47. /// Updates the contents display on the label.
  48. /// </summary>
  49. /// <param name="content">Content to display on the label.</param>
  50. public void SetContent(GUIContent content)
  51. {
  52. Internal_SetContent(mCachedPtr, content);
  53. }
  54. /// <summary>
  55. /// Colors the element with a specific tint.
  56. /// </summary>
  57. /// <param name="color">Tint to apply to the element.</param>
  58. public void SetTint(Color color)
  59. {
  60. Internal_SetTint(mCachedPtr, ref color);
  61. }
  62. [MethodImpl(MethodImplOptions.InternalCall)]
  63. private static extern void Internal_CreateInstance(GUILabel instance, GUIContent content, string style,
  64. GUIOption[] options);
  65. [MethodImpl(MethodImplOptions.InternalCall)]
  66. private static extern void Internal_SetContent(IntPtr nativeInstance, GUIContent content);
  67. [MethodImpl(MethodImplOptions.InternalCall)]
  68. private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color);
  69. }
  70. }