mouse click over the GUI

Hi ,guys
Using GUI,
i create a DragWindow in the scene
"
private Rect winRect;

// Use this for initialization
void Start () {
winRect = new Rect(10, 10, 300, 100);
}

// Update is called once per frame
void Update () {

}

void OnGUI()
{

winRect=GUI.Window(0,winRect,windowsFUN,“the first windows”);

}

void windowsFUN(int windowID)
{

GUI.DragWindow(new Rect(0,0,300,100));

}

"
+____

one cube only attach with this script

"
void Update () {

if (Input.GetMouseButtonUp(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.mainCamera.ScreenPointToRay(Input.mousePosition), out hit, 100))
{

Debug.Log("over the Box "+hit.collider.name);

}
}
"
the question is that when i put the window just over the cube, and click inside the window

the console keeps printing “over the Box XXX”

what i want is that ,when i put the window over the cube ,i click the mouse left button,the Raycast shoud not work. because there 's window is just over the cube.

Is there some solutions for that ?

Why not use a collider and OnTriggerEnter() ?
If there is a GUI Layer over the scene, I think the collider doesn’t trigger.

yes , i tryied the OnMouseDown() function ,it works,

but i just want to find the posibility of another solution.

With a raycast… Maybe set a bool on your object’s script, that disables the raycast if the GUI triggers ?
Or a raycast on the GUI window.

But it may cost a lot if you multiply the raycasts…

Hi guys,

i am trying to make a picture frame in 3d model scene view . I want to know when I click on frame it should show the pic in that and again when I click in frame pic should be disappear. Any idea how to do that?

Sumit

I can’t stop laughing at myself trying to make a window drag able
what I was doing is that I don’t set the window to any variable so I was just using GUI.Window() not a rect variable = GUI.window()
and was kicking myself trying to figure out how I can drag this window and even reading scripting reference I was neglecting to set it to a variable and say to myself how this dragwindow function work lol
I was specifying float variables to the x , y of the rect inside the window and changing those value by setting them to Input.mouse position
and of course when I move my mouse fast the window is left behind , and I did some fancy scripting to be able to drag it withought lossing it stands still if I move the mouse fast , I can tell you how if anyone interested but I’m ashame to do this on my own lol

well , the reason for my reply is to thank Super_apple for starting this topic and include his piece of code which switched a light on in my brain and finally figured out how the heck I’m gonna drag all my future windows with such very easy already implemented feature in unity engine that I didn’t understand well and decided to bypass and work on my own way

THANK YOU VERY MUCH Super