here is what i am trying to do
i have rotation on mouse click and drag, i want to prevent that if mouse is inside rectangle that represents part of the gui (as a window), it works fine but for windows it prevents click+rotation even if the window is not shown, so i am trying to
add one more variable to check, here is what i tried:
if(Input.GetMouseButton(0) !(GUIControlScript.GetOptionsRectangle().Contains(invertedMousePosition)))){
enableSelection=false;
toggleSelection=false;
x += Input.GetAxis("Mouse X") * xSpeed * 0.04;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.04;
}
so this basically means : if mouse button is clicked and mouse is not inside window rectangle go inside.
the question is how to add one more check if the window is visible? GUIControlScript.showWindow variable?
thanks!
Yes it’s possible. Did you try something that made you think it doesn’t work?
if ( Input.Get… … ) {
if ( GUIControlScript.showWindow ) {
}
}
You could also add it as an -
if ( Input.Get otherthing GUIControlScript.showWindow ) {
i know, but the logic is flawed…if window is shown i dont need to check if the mouseposition is inside the gui window rectangle
so i would like to have if statement inside this if statement…i could not make it happen.
there is solution but then you have to duplicate huge part of the code and i would like to avoid that
Order them in the order needed to execute. That is:
if ( Input.GetMouseButton GUIControlScript.showWindow otherthing ) {
Unity checks each item in sequence and doesn’t bother checking the others if it’s not necessary. In this case, it first checks “Input.GetMouseButton”, if that’s false, it doesn’t bother accessing showWindow nor that “otherthing”. Similarly, if Input.GetMouseButton is true, but showWindow is false, it doesn’t call “otherthing”. It will only run “otherthing”'s logic if and only if both GetMouseButton and showWindow are true.
Otherwise, the equivalentmethod would be to simply nest each call:
if ( Input.GetMouseButton GUIControlScript.showWindow otherthing ) {
is the same as:
if ( Input.GetMouseButton )
{
if ( GUIControlScript.showWindow )
{
if ( otherthing )
{
//do stuff
}
}
}