private void EventLauncher_OnPointerDown(UIEventLauncher obj) { if (lockValueWhenPressed) { isLocked = true; lockedValue = slider.value; OnLocked.Invoke(); } }
private void EventLauncher_OnPointerUp(UIEventLauncher obj) { isLocked = false; if (lockValueWhenPressed) { OnUnlocked.Invoke(); slider.value = lockedValue; } }
void OnEnable() { if (slider == null) { slider = GetComponent <Slider>(); } if (lockValueWhenPressed) { if (handleEventLauncher == null) { handleEventLauncher = slider.GetComponent <UIEventLauncher>(); if (handleEventLauncher == null) { handleEventLauncher = slider.gameObject.AddComponent <UIEventLauncher>(); } } handleEventLauncher.OnPointerDown += EventLauncher_OnPointerDown; handleEventLauncher.OnPointerUp += EventLauncher_OnPointerUp;; } slider.onValueChanged.AddListener(OnValueChanged); }