How do I make the camera fit the GUI/screen?
var texScope: Texture; // drag the scope image here
var scopeCam: Camera; // drag the scope camera here
var rCamera = Rect(0, 0, 196, 196);
var rScope = Rect(0, 0, 308, 308);
var enableAim: boolean = false; // set enableAim to true to aim
function OnGUI(){
if (enableAim){
rCamera = ((Rect(0,0, Screen.width, Screen.height)));
rScope = (Rect(0,0, Screen.width, Screen.height));
scopeCam.pixelRect = rCamera;
scopeCam.enabled = true;
GUI.DrawTexture(rScope, texScope, ScaleMode.ScaleToFit, true, 0);
}
else {
scopeCam.enabled = false;
}
}
function Update(){
enableAim = Input.GetMouseButton(1); // aim while the right mouse button is pressed
}
↧