Hi all…
I’ve been struggling with this problem for days. I am trying to achieve a magnifying glass effect so the user can drag around an image, picking up hidden details. I though that by setting up another camera I could just update the Normalised Camera Rect but it doesn’t seem to work. I can see the x and y position numbers updating in the editor, but the rect height and width keeps setting to zero. Any ideas? Or perhaps I’m barking up the wrong tree and need another solution?
using UnityEngine;
using System.Collections;
public class Magnify : MonoBehaviour{
public Camera MagnifyCam;
private Rect rctWindow;
public float posx;
public float posy;
void Update () {
if (Input.GetMouseButton(0)) {
posx = Input.mousePosition.x;
posy = Input.mousePosition.y;
rctWindow = ( new Rect (posx, Screen.height - posy, 1, 1));
MagnifyCam.rect = rctWindow;
}
}
}
OK, I think I have sorted it out… The problem could have been with the UnityRemote getting stuck and affecting Unity itself, so it wasn’t updating… In either case, here is the code that works, if anyone is interested.
var fl_map_width = 220;
var fl_map_height = 220;
var posy : int;
var posx : int;
function FixedUpdate() {
if (Input.GetMouseButton(0)) {
posx = Input.mousePosition.x;
posy = Input.mousePosition.y;
camera.pixelRect = (new Rect (posx, posy, fl_map_width, fl_map_height));
}
}
interesting. I used your script and I couldn’t tell if it actually zooms in or not. do you have it so that the details only show up when using the magnifier or does it actually zoom in? also, do you have some code to set it back to normal? I’m not trying to steal it, I just want to play with it. 
okay, I broke out a ruler and a cube, and due to the smaller size of the magnifier cam, the object actually seems to get smaller, effectively zooming out.