Exemplo n.º 1
0
        void DragEndOnSlider(Transform hit)
        {
            MText_UI_SliderHandle sliderHandle = hit.gameObject.GetComponent <MText_UI_SliderHandle>();

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

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

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

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

            return(false);
        }
Exemplo n.º 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();
        }