GUILabel.cs 3.3 KB

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