Beispiel #1
0
        void DragEndOnSlider(Transform hit)
        {
            MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>();

            if (!InteractWithSlider(sliderHandle))
            {
                return;
            }

            sliderHandle.slider.ValueChangeEnded();
        }
Beispiel #2
0
        void UnselectSlider(Transform hit)
        {
            MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>();

            if (!InteractWithSlider(sliderHandle))
            {
                return;
            }

            sliderHandle.slider.UnSelectedVisual();
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        bool InteractWithSlider(MText_UI_SliderHandle sliderHandle)
        {
            if (!sliderHandle)
            {
                return(false);
            }
            if (sliderHandle.slider && sliderHandle.slider.interactable)
            {
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        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();
        }