public virtual void HandleSubmitSelected() { bool submitInput = InputManager.GetSubmitInput(MathfExtensions.NULL_INT); if (currentSelected.gameObject.activeInHierarchy && (submitInput || (IsMousedOverSelectable(currentSelected) && leftClickInput && !previousLeftClickInput))) { Button button = currentSelected.GetComponent <Button>(); if (button != null) { button.onClick.Invoke(); } else { Toggle toggle = currentSelected.GetComponent <Toggle>(); if (toggle != null) { toggle.isOn = !toggle.isOn; } else { _Slider slider = currentSelected.GetComponent <_Slider>(); if (slider != null) { controllingWithJoystick = submitInput; inControlMode = !inControlMode; } } } } }
public virtual void HandleMouseInput() { if (InputManager.UsingGamepad) { return; } if (!leftClickInput && previousLeftClickInput && !controllingWithJoystick) { inControlMode = false; } foreach (_Selectable selectable in selectables) { if (currentSelected != selectable && IsMousedOverSelectable(selectable) && CanSelectSelectable(selectable)) { ChangeSelected(selectable); return; } } if (leftClickInput) { if (currentInputField != null) { currentInputField.readOnly = true; } _Slider slider = currentSelected.GetComponent <_Slider>(); if (slider != null) { Vector2 closestPointToMouseCanvasNormalized = new Vector2(); if (currentSelected.canvas.renderMode == RenderMode.ScreenSpaceOverlay) { if (selectable != null) { closestPointToMouseCanvasNormalized = slider.slidingArea.GetRectInCanvasNormalized(selectable.canvasRectTrs).ClosestPoint(slider.canvasRectTrs.GetWorldRect().ToNormalizedPosition(InputManager.GetMousePosition(MathfExtensions.NULL_INT))); } } else if (selectable != null) { closestPointToMouseCanvasNormalized = slider.slidingArea.GetRectInCanvasNormalized(selectable.canvasRectTrs).ClosestPoint(slider.canvasRectTrs.GetWorldRect().ToNormalizedPosition(selectable.canvas.worldCamera.ScreenToWorldPoint(InputManager.GetMousePosition(MathfExtensions.NULL_INT)))); } float normalizedValue = slider.slidingArea.GetRectInCanvasNormalized(slider.canvasRectTrs).ToNormalizedPosition(closestPointToMouseCanvasNormalized).x; slider.slider.value = Mathf.Lerp(slider.slider.minValue, slider.slider.maxValue, normalizedValue); if (slider.snapValues.Length > 0) { slider.slider.value = MathfExtensions.GetClosestNumber(slider.slider.value, slider.snapValues); } } else { InputField inputField = currentSelected.GetComponent <InputField>(); if (inputField != null) { currentInputField = inputField; currentInputField.readOnly = false; } } } }
public virtual void ControlSelected() { if (!inControlMode) { return; } _Slider slider = currentSelected.GetComponent <_Slider>(); if (slider != null) { slider.indexOfCurrentSnapValue = Mathf.Clamp(slider.indexOfCurrentSnapValue + MathfExtensions.Sign(inputDirection.x), 0, slider.snapValues.Length - 1); slider.slider.value = slider.snapValues[slider.indexOfCurrentSnapValue]; } }