GUILabel.cs 3.3 KB

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