ImageFontSprite.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using CommonUI.Data;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace CommonUnity3D.UGUI
  7. {
  8. public class ImageFontSprite : DisplayText
  9. {
  10. private ImageFontGraphics mGraphics;
  11. public ImageFontSprite(string name = "") : base(name)
  12. {
  13. this.Enable = false;
  14. this.EnableChildren = false;
  15. this.mGraphics = mGameObject.AddComponent<ImageFontGraphics>();
  16. }
  17. public ImageFontGraphics Graphics
  18. {
  19. get { return mGraphics; }
  20. }
  21. public override string Text
  22. {
  23. get { return mGraphics.Text; }
  24. set
  25. {
  26. if (IsDispose) return;
  27. this.mGraphics.Text = value;
  28. }
  29. }
  30. public override CommonUI.Data.TextAnchor Anchor
  31. {
  32. get { return mGraphics.Anchor; }
  33. set { this.mGraphics.Anchor = value; }
  34. }
  35. public override Color FontColor
  36. {
  37. get { return mGraphics.FontColor; }
  38. set { mGraphics.FontColor = value; }
  39. }
  40. public override Vector2 TextOffset
  41. {
  42. get { return mGraphics.TextOffset; }
  43. set { this.mGraphics.TextOffset = value; }
  44. }
  45. public override int FontSize
  46. {
  47. get { return 1; }
  48. set { }
  49. }
  50. public override CommonUI.Data.FontStyle Style
  51. {
  52. get { return CommonUI.Data.FontStyle.Normal; }
  53. set { }
  54. }
  55. public override bool IsUnderline
  56. {
  57. get { return false; }
  58. set { }
  59. }
  60. public override Vector2 PreferredSize
  61. {
  62. get { return mGraphics.PreferredSize; }
  63. }
  64. public override Rect LastCaretPosition
  65. {
  66. get { return mGraphics.LastCaretPosition; }
  67. }
  68. public void SetAtlas(CommonUI.Cell.CPJAtlas atlas)
  69. {
  70. this.mGraphics.Atlas = atlas;
  71. }
  72. protected override void OnUpdate()
  73. {
  74. base.OnUpdate();
  75. }
  76. public override void SetBorder(Color bc, Vector2 distance)
  77. {
  78. //Do nothing.
  79. }
  80. public override void SetShadow(Color bc, Vector2 distance)
  81. {
  82. }
  83. public override void SetFont(UnityEngine.Font font)
  84. {
  85. }
  86. }
  87. }