BMSymbol.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using UnityEngine;
  3. [Serializable]
  4. public class BMSymbol
  5. {
  6. public int length
  7. {
  8. get
  9. {
  10. if (this.mLength == 0)
  11. {
  12. this.mLength = this.sequence.Length;
  13. }
  14. return this.mLength;
  15. }
  16. }
  17. public int offsetX
  18. {
  19. get
  20. {
  21. return this.mOffsetX;
  22. }
  23. }
  24. public int offsetY
  25. {
  26. get
  27. {
  28. return this.mOffsetY;
  29. }
  30. }
  31. public int width
  32. {
  33. get
  34. {
  35. return this.mWidth;
  36. }
  37. }
  38. public int height
  39. {
  40. get
  41. {
  42. return this.mHeight;
  43. }
  44. }
  45. public int advance
  46. {
  47. get
  48. {
  49. return this.mAdvance;
  50. }
  51. }
  52. public Rect uvRect
  53. {
  54. get
  55. {
  56. return this.mUV;
  57. }
  58. }
  59. public void MarkAsChanged()
  60. {
  61. this.mIsValid = false;
  62. }
  63. public bool Validate(UIAtlas atlas)
  64. {
  65. if (atlas == null)
  66. {
  67. return false;
  68. }
  69. if (!this.mIsValid)
  70. {
  71. if (string.IsNullOrEmpty(this.spriteName))
  72. {
  73. return false;
  74. }
  75. this.mSprite = ((!(atlas != null)) ? null : atlas.GetSprite(this.spriteName));
  76. if (this.mSprite != null)
  77. {
  78. Texture texture = atlas.texture;
  79. if (texture == null)
  80. {
  81. this.mSprite = null;
  82. }
  83. else
  84. {
  85. this.mUV = new Rect((float)this.mSprite.x, (float)this.mSprite.y, (float)this.mSprite.width, (float)this.mSprite.height);
  86. this.mUV = NGUIMath.ConvertToTexCoords(this.mUV, texture.width, texture.height);
  87. this.mOffsetX = this.mSprite.paddingLeft;
  88. this.mOffsetY = this.mSprite.paddingTop;
  89. this.mWidth = this.mSprite.width;
  90. this.mHeight = this.mSprite.height;
  91. this.mAdvance = this.mSprite.width + (this.mSprite.paddingLeft + this.mSprite.paddingRight);
  92. this.mIsValid = true;
  93. }
  94. }
  95. }
  96. return this.mSprite != null;
  97. }
  98. public string sequence;
  99. public string spriteName;
  100. private UISpriteData mSprite;
  101. private bool mIsValid;
  102. private int mLength;
  103. private int mOffsetX;
  104. private int mOffsetY;
  105. private int mWidth;
  106. private int mHeight;
  107. private int mAdvance;
  108. private Rect mUV;
  109. }