- Home /
If not over interface
Hi, I've just made a camera script in which you can drag the camera along the ground. I've also implemented a horizontal slider which zooms along the Y axis of the camera.
This all works perfectly, but I had a small question. How could I prevent the dragging if the mouse is over an interface element?
Thanks in advance!
Answer by Berenger · May 14, 2012 at 10:29 PM
If all your GUI stuff are in only one script, then check if the mouse is hover one of the rect with Rect.Contains. Make sure to do this in Update and to group the rects as much as possible.
If they are splitted into several scripts, it's a bit trickier. I suggest you make all those script give their rects to a master script which will do the testing.
Answer by tw1st3d · May 14, 2012 at 10:26 PM
var isHover : GUIStyle;
function Start()
{
Time.timeScale == 1;
}
function Update()
{
if(isHover.onHover){
Time.timeScale == 0;
}else{
Start();
}
}
That should work, although you may need to play around with the .onHover area, because I haven't used that before, so I'm not sure if it's bugproof. }
Your answer
Follow this Question
Related Questions
How to group variables in the Inspector? 5 Answers
Bad result of changing RectTransform values (Anchor Preset) programmatically 0 Answers
How do you make a HUD Interface that expands with resolution (Game Border/GUI) 1 Answer
Gui Login With Interface 1 Answer
Airlock Door Code Problems [Solved] 1 Answer