hello I’m developing 2D games where I have a 2dTexture with quad for its surface. The problem is whenever I change the frame form animations, the textures also have different size of pixels in some frame, So my quad’s size can’t follow the size of the texture because the quad size is in unity units size, and the texture is in pixel size, is there any simple way to do this? Really appreciated your answer… Thank you so much
For an Orthographic Camera, you can do something like this with Unity’s built-in Quad:
function SetToPixelPerfect() {
var texture = renderer.material.mainTexture;
var scale = (Screen.height / 2.0) / Camera.main.orthographicSize;
transform.localScale.x = texture.width / scale;
transform.localScale.y = texture.height / scale;
}