i have 2 camera in my game one camera having zoom script
other camera dont have that scrip
While mouse pointer moving over other camera the non script camera detecting the zoom script.how to stop mouse not detect other camera script .while moving over that camera
check out:
i have attached sample project attached with this thread to make the question clear!
1211585–49279–$New Unity Project 16.rar (144 KB)
You could place an invisible collider in front of the camera to stop any raycast getting through…
Karl
no i have some mouse clicking function in other camera place
can you please explain more?
Hi Unity3D_Team,
I didn’t see you attachment.
Probably you are having both cameras with same Name / Tag to access in Zoom Script.
Okay… There is a way but not sure if its optimized. I can’t write code, but giving you a concept.
Draw a GUI Label with Rect(say m_rectCam2) with size same as of camera2 on camera2.
Keep a boolean variable say m_isInCam2Area = false
Now keep OnGUI() in script which have code:
Vector2 l_mousePos = Input.mousePosition;
if(m_rectCam2.Contains(l_mousePos) ) //if mouse is in cam 2 area
{
m_isInCam2Area = true;
}
void Update()
{
if(m_isInCam2Area) //if camera2 is in Cam2Area, then DoNothing.
return;
if(target)
{
…
…
}
}