2dtoolkit获取sprite像素大小的方法
获取sprite像素的方法
Vector2 GetPixelSize(tk2dSpriteDefinition def){ float w = def.untrimmedBoundsData[1].x; float h = def.untrimmedBoundsData[1].y; // Calculate dimensions in pixel units float pixelWidth = w / def.texelSize.x; float pixelHeight = h / def.texelSize.y; Vector2 sizeVec = new Vector2(pixelWidth, pixelHeight); return sizeVec; }
其中的def参数只要转入spirte实例的CurrentSprite属性就可以了,slicedSprite同理