[Sorry if this is answered elsewhere, I usually can find answers here or the forums but have been hunting for a while and can't find exactly what I need.]
This a side-view 2D game. There are two active orthographic cameras: the 'Main' camera that can scroll back and forth by clicking and dragging; and the 'Stationary' camera that always points to a certain part of the level. The stationary cam's display is in one corner of the screen and at a higher depth than the main cam so it displays on top. The problem is I need mouse clicks in the stationary cam's viewing area to do something other than scroll the main cam.
It seems there may be a 'screenpointtoray' type of solution, and I've played with a GUI box of the same size as the stationary viewing area, but I'm too much of a newb to experiment on my own very much.
Hopefully that made sense...
Any help is greatly appreciated!
-JC
I think there's probably more than one way this could be handled. I'll offer a couple of suggestions (although I may end up overlooking alternate solutions that might be easier or more straightforward).
The Camera class has a 'pixelRect' member field that specifies the camera viewport in pixel coordinates. Input.mousePosition is also in pixel coordinates, and the Rect class includes a point containment function, so at any time you should be able to determine whether the cursor is in the secondary camera's view as follows (untested):
bool inView = camera.pixelRect.Contains(Input.mousePosition);
Where you put this code is of course up to you; all that's required is that the secondary camera (or at least its screen-space viewport rect) is accessible.
From there, you can take the appropriate action based on the current mouse position. You should be able to use ScreenPointToRay() with either camera to generate a valid picking ray. (I can't remember off the top of my head what the behavior of this function is when the input point is outside of the camera's pixel rect, but as long as the point is within the rect, the output should be valid.)