Question by
unity_h36Dp8nmGLPPVA · Jun 26, 2020 at 11:08 PM ·
dragsliderdetecting
Detecting if slider is dragged
I want to detect whether the user is dragging the slider. In the update, I am calling some functions based on either user is dragging the slider or not. I use the interfaces " IPointerDownHandler" and "IPointerUpHandler". I have a bool statement which supposed to become true if the user drags the slider. But it does not work meaning that my bool is always false during the Game and never become true. The Event Trigger is added to the slider with 2 types of event: "PointerUp" and "PointerDown". ( I am not sure if this part is necessary though) This is part of my code. Can Anybody take a look and see what is the problem? Thank you!
public class MyClass : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
bool IsSliderClicked = false;
void Update()
{
if (IsSliderClicked)
{
TransformMatrix();
DrawArc(theta, modelPivot)
UpdateGizmo();
}
else
{
UpdateGizmo();
}
public void OnPointerDown(PointerEventData eventData)
{
IsSliderClicked = true;
}
public void OnPointerUp(PointerEventData eventData)
{
IsSliderClicked = false;
}
}
Comment