I have a basic transform script that rotates a 3D object, it’s a 3D medical DICOM “image” of a skull.
I have set up slider controls, to adjust brightness and other stuff.
Now when I click and move the thumb of the slider control, my transform script is still in effect and is rotating the 3D skull, as I scrub back and forth the thumb of the slider.
What is the proper way to disable the transform script or script action, until I stop using the slider?
When I click the slider, I want the script turned off.
When I release the mouse button, I want the script turned on.
I know how to write the script to turn it on and off…that’s not the issue…
I need to turn it off when I actually click on the slider, there is no “mouse down” event on the slider, at least that I know of. And no “mouse up” event on the slider.
How do I use a Custom Slider …like below…?
I don’t mean how to create the script file, how do I add this slider to a canvas in Unity3D like a regular slider?
Declare a new class that inherits from Slider class and overriding the OnPointerDown() method like this:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class CustomSlider: Slider
{
public override void OnPointerDown(PointerEventData eventData)
{
base.OnPointerDown(eventData);
// Your code here
}
}
To the canvas? I tried, when I run app, the derived slider does not show up.
Dragging to Canvas, #1, adds it as a component of Canvas, but it does not appear as a child slider node of canvas, nor does it appear in 2D viewport, #2, so that I can adjust its location etc…