- Home /
The question is answered, right answer was accepted
I ask one thing about resizing with different resolution.
I am making a sort of 2D game, then i faced a problem. I draw a sprite 1280 x 720 px with orho camera. and my project resolution is 1280 x 720. Anyways, the sprite is always drawn same size(1280 x 720) of course. however, when i changed the the resolution, i mean, different aspect ratio, i need to re-size or scale the sprite with the resolution. anyone has any ideas? Thanks.
added, I need to re-size UV values. I think. :)
How are you drawing the sprite? Is it a GUITexture or a plane?
Why ask a question and not respond to any comments or answers!? lol XD
Answer by clunk47 · Jul 26, 2013 at 01:46 PM
If you are using a GUI code to draw your sprite, and you want it fullscreen, just set the Rect of the sprite to the screen width and height, of course starting the location at 0x, 0y. Here is an example of how to set a Rect at startup, then have the rect always be equal to the screen resolution.
//C# Example
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
Rect spriteRect;
public Texture2D sprite;
void Update()
{
spriteRect = new Rect(0, 0, Screen.width, Screen.height);
}
void OnGUI()
{
GUI.DrawTexture(spriteRect, sprite);
}
}