1
\$\begingroup\$

I am using the UI slider from Unity 5 and would like to display a text every time the handle knob is touched/pressed.

My understanding is that my script should extend some Event System interface. From the unity doc either ISelectHandler or IPointDownHandler should be able to 'hear' if my knob is pressed. I am a noobie to the unity event system, so I hope that this question doesn't offend anyone if its pretty basic..

So far this is what I have:

public class SliderControl : MonoBehaviour, ISelectHandler {

    public Slider slider;

    void Start(){
        slider.transform.GetChild (2); // this gets the Handle Slide Area where the knob is
    }

    public void OnSelect (BaseEventData eventData) {
        Debug.Log ("Display some text");
    }
}

My questions are:

  1. What exactly is a base event data in simple English?

  2. How can I convert my slider knob into a BaseEventData type that OnSelect() can work with?

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

Easiest way to do it by adding an Event Trigger component to the knob for Pointer Enter or Pointer Down and call a public method through it.

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .