Sprite的几个属性的解释
1) Rect rect;
a) Sprite Mode为Single时: x, y总是为0; width, height为裁掉空白像素前的大小
b) Sprite Mode为Multiple时: 则x, y为slice区域在Sprite上的位置, 大小为slice区域的大小
2) Vector2 textureRectOffset;
左下角裁掉了多少空白像素, 只有Sprite的MeshType为Tight时空白像素才会被裁掉
3) Rect textureRect;
x, y为Sprite左下角的坐标(图集左下角为原点); width, height为裁掉空白像素后的大小
4) Vector4 padding = UnityEngine.Sprites.DataUtility.GetPadding(sp);
上下左右裁掉的空白像素大小
5) Vector4 outerUV = UnityEngine.Sprites.DataUtility.GetOuterUV(sp);
左下角和右上角在图集上的uv值
6) Vector4 border;
9宫格4个区域的大小
7) Vector4 innerUV = UnityEngine.Sprites.DataUtility.GetInnerUV(sp);
innerUV.xy = outerUV.xy - paddingUV.xy + borderUV.xy
innerUV.zw = outerUV.zw + paddingUV.zw - borderUV.zw
8)Vector2 minSize = UnityEngine.Sprites.DataUtility.GetMinSize(sp);
minSize.x = border.x+border.z
minSize.y = border.y+border.w
9) Bounds bounds = sp.bounds;
center为裁掉空白像素前的中心的坐标(以pivot为原点),extends总是为长,宽的一半
center = (0.5 - pivot) * 裁掉空白像素前的大小 / 像素每世界空间单位
extends = 裁掉空白像素前的大小 * 0.5 / 像素每世界空间单位
示例
1) icon_bomb
a) 没有9宫: border: (0, 0, 0, 0)
b) 裁掉了空白像素:
textureRectOffset: (25.1, 7.1), 左下角裁掉的大小
padding: (25.07612, 7.07612, 25.02675, 7.076118), 左下和右上裁掉的大小
rect: (x:0, y:0, w:128, h:128), 裁掉空白像素前的大小为128x128
textureRect: (x:107.0761, y:0.07612038, w:77.89713, h:113.8478), 裁掉空白像素后大小为77.89713x113.8478
c) 其他
bounds: center:(0, 0, 0), extends:(0.64, 0.64, 0.1)
pivot: (64, 64)
d) 在图集上的区域(红色为outer, 绿色为inner)
outerUV: (0.4182661, 0.0002973452, 0.7225518, 0.4450152)
innerUV: (0.3203125, -0.02734375, 0.8203125, 0.4726563)
2) icon_bg
a) 有9宫: border: (36, 39, 38, 37)
b) 裁掉了空白像素:
textureRectOffset: (8.0, 8.0), 左下角裁掉的大小
padding: (8.026751, 8.026751, 8.076118, 8.076118), 左下和右上裁掉的大小
rect: (x:0, y:0, w:117, h:118), 裁掉空白像素前大小为117x118
textureRect: (x:0.02675056, y:0.02675056, w:100.8971, h:101.8971), 裁掉空白像素后大小为100.8971x101.8971
c) 其他
bounds: center:(0, 0, 0), extends:(0.585, 0.59, 0.1)
pivot: (58.5, 59)
d) 在图集上的区域(红色为outer, 绿色为inner)
outerUV: (0.0001044944, 0.0001044944, 0.3942339, 0.3981402)
innerUV: (0.109375, 0.1210937, 0.2773438, 0.2851563)
3) highlight
a) 有9宫: border: (26, 29, 28, 27)
b) 没有裁掉空白像素:
texRectOffset: (0.0, 0.0)
padding: (0, 0, 0, 0)
rect: (x:0, y:0, w:103, h:97), 没裁掉空白像素, 大小为103x97
texRect: (x:0, y:106, w:103, h:97)
c) 其他
bounds: center:(0, 0, 0), extends:(0.515, 0.485, 0.1)
pivot: (51.5, 48.5)
d) 在图集上的区域(红色为outer, 绿色为inner)
outerUV: (0, 0.4140625, 0.4023438, 0.7929688)
innerUV: (0.1015625, 0.5273438, 0.2929688, 0.6875)
4) btn_help
a) 没有9宫: border: (0, 0, 0, 0)
b) 没有裁掉空白像素:
textureRectOffset: (0.0, 0.0)
padding: (0, 0, 0, 0)
rect: (x:0, y:0, w:74, h:75)
textureRect: (x:107, y:118, w:74, h:75)
c) 自定义了pivot:
pivot: (29.6, 22.5)
d) 其他
bounds: center:(0.074, 0.15, 0), extends:(0.37, 0.375, 0.1)
f) 在图集上的区域(红色为outer, 绿色为inner, 重叠在一起了)
innerUV: (0.4179688, 0.4609375, 0.7070313, 0.7539063)
outerUV: (0.4179688, 0.4609375, 0.7070313, 0.7539063)
5) icons的子切片icon_1
a) Sprite Mode为Multiple:
rect: (x:76, y:12, w:55, h:50), xy为slice区域在Sprice上的位置, wh为slice区域的大小
b) 没有9宫: border: (0, 0, 0, 0)
c) 没有裁掉空白像素:
textureRectOffset: (0.0, 0.0)
padding: (0, 0, 0, 0)
textureRect: (x:107, y:197, w:55, h:50)
d) 其他
bounds: center:(0, 0, 0), extends:(0.275, 0.25, 0.1)
pivot: (27.5, 25)
f) 在图集上的区域(红色为outer, 绿色为inner, 重叠在一起了)
outerUV: (0.4179688, 0.7695313, 0.6328125, 0.9648438)
innerUV: (0.4179688, 0.7695313, 0.6328125, 0.9648438)