-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMSymbol.cs
83 lines (71 loc) · 2.36 KB
/
BMSymbol.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Decompiled with JetBrains decompiler
// Type: BMSymbol
// Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
using System;
using UnityEngine;
[Serializable]
public class BMSymbol
{
private int mAdvance;
private int mHeight;
private bool mIsValid;
private int mLength;
private int mOffsetX;
private int mOffsetY;
private UIAtlas.Sprite mSprite;
private Rect mUV;
private int mWidth;
public string sequence;
public string spriteName;
public void MarkAsDirty() => this.mIsValid = false;
public bool Validate(UIAtlas atlas)
{
if (Object.op_Equality((Object) atlas, (Object) null))
return false;
if (!this.mIsValid)
{
if (string.IsNullOrEmpty(this.spriteName))
return false;
this.mSprite = Object.op_Equality((Object) atlas, (Object) null) ? (UIAtlas.Sprite) null : atlas.GetSprite(this.spriteName);
if (this.mSprite != null)
{
Texture texture = atlas.texture;
if (Object.op_Equality((Object) texture, (Object) null))
{
this.mSprite = (UIAtlas.Sprite) null;
}
else
{
Rect rect = this.mSprite.outer;
this.mUV = rect;
if (atlas.coordinates == UIAtlas.Coordinates.Pixels)
this.mUV = NGUIMath.ConvertToTexCoords(this.mUV, texture.width, texture.height);
else
rect = NGUIMath.ConvertToPixels(rect, texture.width, texture.height, true);
this.mOffsetX = Mathf.RoundToInt(this.mSprite.paddingLeft * ((Rect) ref rect).width);
this.mOffsetY = Mathf.RoundToInt(this.mSprite.paddingTop * ((Rect) ref rect).width);
this.mWidth = Mathf.RoundToInt(((Rect) ref rect).width);
this.mHeight = Mathf.RoundToInt(((Rect) ref rect).height);
this.mAdvance = Mathf.RoundToInt(((Rect) ref rect).width + (this.mSprite.paddingRight + this.mSprite.paddingLeft) * ((Rect) ref rect).width);
this.mIsValid = true;
}
}
}
return this.mSprite != null;
}
public int advance => this.mAdvance;
public int height => this.mHeight;
public int length
{
get
{
if (this.mLength == 0)
this.mLength = this.sequence.Length;
return this.mLength;
}
}
public int offsetX => this.mOffsetX;
public int offsetY => this.mOffsetY;
public Rect uvRect => this.mUV;
public int width => this.mWidth;
}