123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using UnityEngine;
- [Serializable]
- public class BMSymbol
- {
- public int length
- {
- get
- {
- if (this.mLength == 0)
- {
- this.mLength = this.sequence.Length;
- }
- return this.mLength;
- }
- }
- public int offsetX
- {
- get
- {
- return this.mOffsetX;
- }
- }
- public int offsetY
- {
- get
- {
- return this.mOffsetY;
- }
- }
- public int width
- {
- get
- {
- return this.mWidth;
- }
- }
- public int height
- {
- get
- {
- return this.mHeight;
- }
- }
- public int advance
- {
- get
- {
- return this.mAdvance;
- }
- }
- public Rect uvRect
- {
- get
- {
- return this.mUV;
- }
- }
- public void MarkAsChanged()
- {
- this.mIsValid = false;
- }
- public bool Validate(UIAtlas atlas)
- {
- if (atlas == null)
- {
- return false;
- }
- if (!this.mIsValid)
- {
- if (string.IsNullOrEmpty(this.spriteName))
- {
- return false;
- }
- this.mSprite = ((!(atlas != null)) ? null : atlas.GetSprite(this.spriteName));
- if (this.mSprite != null)
- {
- Texture texture = atlas.texture;
- if (texture == null)
- {
- this.mSprite = null;
- }
- else
- {
- this.mUV = new Rect((float)this.mSprite.x, (float)this.mSprite.y, (float)this.mSprite.width, (float)this.mSprite.height);
- this.mUV = NGUIMath.ConvertToTexCoords(this.mUV, texture.width, texture.height);
- this.mOffsetX = this.mSprite.paddingLeft;
- this.mOffsetY = this.mSprite.paddingTop;
- this.mWidth = this.mSprite.width;
- this.mHeight = this.mSprite.height;
- this.mAdvance = this.mSprite.width + (this.mSprite.paddingLeft + this.mSprite.paddingRight);
- this.mIsValid = true;
- }
- }
- }
- return this.mSprite != null;
- }
- public string sequence;
- public string spriteName;
- private UISpriteData mSprite;
- private bool mIsValid;
- private int mLength;
- private int mOffsetX;
- private int mOffsetY;
- private int mWidth;
- private int mHeight;
- private int mAdvance;
- private Rect mUV;
- }
|