UELabel.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using CommonLang.Xml;
  2. using CommonUnity3D.UGUI;
  3. using System;
  4. using System.Xml;
  5. using UnityEngine;
  6. using CommonUI.Data;
  7. using TextAnchor = CommonUI.Data.TextAnchor;
  8. using FontStyle = CommonUI.Data.FontStyle;
  9. using CommonUI.Cell;
  10. namespace CommonUnity3D.UGUIEditor.UI
  11. {
  12. public class UELabel : UETextComponent
  13. {
  14. public UELabel() : this(UIEditor.GlobalUseBitmapText)
  15. {
  16. }
  17. public UELabel(bool use_bitmap) : base(use_bitmap)
  18. {
  19. this.Enable = false;
  20. this.EnableChildren = false;
  21. }
  22. public UELabel(string text, UILayout layout = null, CPJAtlas imageFont = null, bool use_bitmap = false) : base(use_bitmap)
  23. {
  24. this.Enable = false;
  25. this.EnableChildren = false;
  26. if (layout != null)
  27. {
  28. if (imageFont != null)
  29. {
  30. var vt = new ImageFontSprite("image_font");
  31. vt.SetAtlas(imageFont);
  32. this.mTextSprite = vt;
  33. }
  34. else if (base.mUseBitmapFont)
  35. {
  36. mTextSprite = new BitmapTextSprite("bitmap_text");
  37. }
  38. else
  39. {
  40. mTextSprite = new TextSprite("text");
  41. }
  42. this.AddChild(mTextSprite);
  43. }
  44. else
  45. {
  46. if (imageFont != null)
  47. {
  48. var vt = mGameObject.AddComponent<ImageFontGraphics>();
  49. this.mTextGraphics = vt;
  50. vt.Atlas = imageFont;
  51. }
  52. else if (base.mUseBitmapFont)
  53. {
  54. this.mTextGraphics = mGameObject.AddComponent<BitmapTextGraphics>();
  55. }
  56. else
  57. {
  58. this.mTextGraphics = mGameObject.AddComponent<TextGraphics>();
  59. }
  60. }
  61. this.Text = text;
  62. }
  63. }
  64. }