Drag-able GUI mask

I’m not sure if my subject describes the problem accurately, but here goes.

I want to simulate the effect of looking through binoculars at objects in the scene. I don’t need any magnification through the binoculars - I just need it to reveal objects as I move over them. I’m developing this for the iPad, so I want to be able to drag the binoculars using my finger to any point on the screen and get information on the object visible through the binoculars.

I’ve attached an image to visualize what I’m describing.

I’m not sure what kind of texture I need to create for the binocular mask.

a. Should I create a large (double resolution) GUITexture with the binocular cutout in the middle so that no matter where I drag it on the screen, the rest of the screen will still be black.

b. Should I create a smaller texture of just the binocular cutout and then generate the surrounding black textures in the OnGUI() call?

c. Is there a better way to do what I’m trying?

I appreciate any help on this! Thanks!

446145--15518--$example.png

I figured out how to solve this problem, and it ended up being much simpler than my options.

For anyone interested, this is what I did:

  1. The actual cutout is a 256x256 texture.

  2. I made a 1x1 texture of one black pixel

  3. I assigned the cutout to one GUI texture

  4. I made 4 GUI Textures with the black texture (I made a prefab and then made 4 instances actually)

  5. I made these into children of the cutout texture.

  6. I set the pixel insets of each of the 4 textures so that they lined up with the sides of the cutout texture and adjusted their dimensions so that they would cover the screen no matter where they were placed.
    ex. the black box on the left would be X = -128, Y = -768, width = -1024, height = 1524 (768 x 2)

  7. I attached my drag and drop script on the parent cutout texture - and that was it!

this is not a real mask though