How to disable script during button click

Hi everyone,

I´m struggling a bit with something that might be simple, unfortunately I´m not a programmer, but I´m doing what I can.
I´m working on the UI of a 3d model viewer. Right now I have a camera that rotates around the model on mouse drag, using a script. Problem is that clicking on a UI object like a button or a slider also makes the camera moves as the click gets through the UI. a Simple solution would be to disable the script on the camera “while” the button/slider is clicked. Any help is appreciated.

Thanks

it sounds like you need to setup on the UI object. OnClick() event, to access the camera rotate script and disable it. Then OnMouseUp enable the rotate script.
I know this isn’t much help. I don’t even know that it will work. because you’re also talking about the scroll bar.
Maybe the easiest thing to do would be to have the rotate script look for key pressed and mouse drag for it to rotate the camera. IE : press and hold the SHIFT key plus mouse drag.
Then when you drag the mouse on the scroll bar it will not rotate the object.

1 Like

hm, I´m using an editor called easyGUI, I know that using this kind of stuff while on one side speeds up the work, on the other it limits on some parts, specially if these options like you said are missing. At least from what I´m understanding. Would a script to be add to any UI object, that disables the camera script, work?

can you post the code you are using for the dragging to rotate the camera.

Edit - I think I misread exactly what your problem was, so this might not help

I had a similar challenge when I wrote my camera control script. I wanted the user to hold right mouse to rotate the camera around. But when the user started holding right mouse it would click and when they clicked it would let the camera move for an instant. I had to write some code that would tell the difference between a click and a hold.

I’m at work now but I’ll post the code when I get home.
Basically what it did was:

Float timer
Float hold threshold
Update ()
{
Is right mouse down
    increment timer by time.delta time.
    is timer over hold threshold
        fire event started holding
Else if Right mouse is not down
    is timer over hold threshold
        fire event ended holding
    else if timer under hold threshold
        fire event right mouse clicked
    reset timer to 0
}

IsRightMouseHeldDown ()
{
    if timer over hold threshold
        return true
    return false
}

Was the general gist of it.