void DragEndOnSlider(Transform hit) { MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>(); if (!InteractWithSlider(sliderHandle)) { return; } sliderHandle.slider.ValueChangeEnded(); }
void UnselectSlider(Transform hit) { MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>(); if (!InteractWithSlider(sliderHandle)) { return; } sliderHandle.slider.UnSelectedVisual(); }
void PressSlider(Transform hit) { MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>(); if (!InteractWithSlider(sliderHandle)) { return; } hit.gameObject.GetComponent <MText_UI_SliderHandle>().slider.ClickedVisual(); }
bool InteractWithSlider(MText_UI_SliderHandle sliderHandle) { if (!sliderHandle) { return(false); } if (sliderHandle.slider && sliderHandle.slider.interactable) { return(true); } return(false); }
void DragSlider(Transform hit) { MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>(); if (!InteractWithSlider(sliderHandle)) { return; } Vector3 screenPoint = myCamera.WorldToScreenPoint(hit.position); Vector3 cursorScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z); Vector3 cursorPosition = myCamera.ScreenToWorldPoint(cursorScreenPoint); float size = sliderHandle.slider.backgroundSize; Vector3 localPosition = hit.InverseTransformPoint(cursorPosition); localPosition = new Vector3(localPosition.x, 0, 0); localPosition.x = Mathf.Clamp(localPosition.x, -size / 2, size / 2); hit.localPosition = localPosition; sliderHandle.GetCurrentValueFromHandle(); sliderHandle.slider.ValueChanged(); }