- Home /
Overlay image on center of screen.
I've got an image that I want to overlay over the camera. It's 1920x1080 but I would like it to automatically resize it to the current screen resolution. Here is the image:
How would I do this? This code works but it doesn't resize the image.
var crosshairTexture : Texture2D;
function OnGUI () {
GUI.DrawTexture(Rect(((Screen.width/2)-(crosshairTexture.width/2)),((Screen.height/2)-(crosshairTexture.height/2)),crosshairTexture.width,crosshairTexture.height), crosshairTexture, ScaleMode.ScaleToFit, true, 0.0f);
}
cam_overlay_01.png
(23.0 kB)
Comment
Best Answer
Answer by clunk47 · Aug 07, 2013 at 08:49 PM
#pragma strict
private var rect : Rect;
var image : Texture2D;
function Update ()
{
rect = new Rect(0, 0, Screen.width, Screen.height);
}
function OnGUI()
{
GUI.DrawTexture(rect, image, ScaleMode.StretchToFill);
}