Stop the camera from rotating when dragging a GUI.slider

I have a small UI menu with a bunch of sliders, and I have underlying view with a 3D model. When I hold left mouse button and move mouse the 3D model rotates (kind of 3D viewer).
However I don’t want my model to rotate when I drag the slider. Is there a way to block further mouse events when slider is being dragged, or check if some UI element is being used to prevent camera rotation?

This question is exactly the same as this one: https://forum.unity3d.com/threads/stop-the-camera-from-rotating-when-dragging-a-gui-slider.186301/

However the proposed solution with GUIUtility.hotControl does not work! hotControl is always 0 in my project, no matter what I do with my sliders and buttons.

You can put an Image element above the Slider that is only covering the slider, and nothing else.

Then you make that image’s Alpha color 0, so it is invisible.

Next, you put a Button component on the Image.

Make a public function on your script with the other mouse events and call it stopMouseEvents();.

Create a public boolean variable sliderIsClicked.

In the stopMouseEvents(); function, put " sliderIsClicked = true; "

In the Update Function, type:

if (Input.GetMouseButtonUp(0)) {
    
    sliderIsClicked = false;
    
}

Drag the script onto any GameObject, just make sure it is one that won’t get destroyed. I like to make a seperate Empty GameObject specifically for Scripts.

Now to to the Image with the button that you created and scroll down to the bottom of the button and click the little + icon to add an event when the button is clicked.

Drag the GameObject with the script on it from the Hierarchy to the Script Object In the Button component.

Click on the dropdown now and select your script’s name and then select stopMouseEvents();.

You should be good to go! The only problem that may arise is now you can’t use your slider. This happens because the Image with the button component is above the slider, so Unity is just clicking the Image above the slider, and not the actual slider. To fix this, Instead of putting the Button component with stopMouseEvents(); on a new Image, Put the button component with stopMouseEvents(); on The slider handle that you click and drag.

Hey @sun_stealer
Jason Weimann on YouTube has a great solution here

You’ll need line 2 and lines 8 to 11