/// <summary> /// Applies all non-null input properties in the given Input to the existing input. /// If appendOver is set to true, then all non-null values will replace any values currently existing. /// If appendOver is set to false, then all non-null values will only replace null values in the current input. /// </summary> /// <param name="input">Input to apply properties under this objects properties.</param> /// <param name="appendOver">Appends these values over existing values.</param> public void AppendInput(InputValues input, bool appendOver = true) { if (appendOver) { Input.ApplyOver(input); } else { Input.ApplyUnder(input); } }
/// <summary> /// Forces null values to be 0 instead if the mouse is down and it's set to do that. /// </summary> /// <param name="input">Input to enforce</param> private void Enforce0NotNull(InputValues input) { if (!Use0NotNullWhileMouseInputDown || !Input.GetButton(MouseInputButtonName)) { return; } input.Horizontal = input.Horizontal.HasValue ? input.Horizontal.Value : 0; input.Vertical = input.Vertical.HasValue ? input.Vertical.Value : 0; input.ZoomIn = input.ZoomIn.HasValue ? input.ZoomIn.Value : 0; input.ZoomOut = input.ZoomOut.HasValue ? input.ZoomOut.Value : 0; }
/// <summary> /// Tries to smooth out input values if enabled. /// </summary> public InputValues TrySmooth(InputValues inputValues) { if (!_inputComponent.Smoothing.Enabled) { return(inputValues); } return(new InputValues() { Horizontal = Horizontal.TrySmooth(inputValues.Horizontal, _inputComponent.Smoothing.Horizontal), Vertical = Vertical.TrySmooth(inputValues.Vertical, _inputComponent.Smoothing.Vertical), ZoomIn = ZoomIn.TrySmooth(inputValues.ZoomIn, _inputComponent.Smoothing.ZoomIn), ZoomOut = ZoomOut.TrySmooth(inputValues.ZoomOut, _inputComponent.Smoothing.ZoomOut), }); }
/// <summary> /// Processes the given input and returns a newly created object with the input sensitivities, inversions, and enablings of this component setup properly. /// </summary> /// <param name="input">Input to process.</param> /// <returns></returns> public InputValues ProcessInput(InputValues input) { if (input != null) { InputValues result = input.Copy(); result.NullOutValues(!EnableHorziontal, !EnableVertical, !EnableZoomIn, !EnableZoomOut); result.MultiplyBy(Sensitivity.Horizontal, Sensitivity.Vertical, Sensitivity.ZoomIn, Sensitivity.ZoomOut); result.InvertValues(Invert.Horizontal, Invert.Vertical, Invert.ZoomIn, Invert.ZoomOut); return(result); } else { return(null); } }
/// <summary> /// Modifies the given InputValues object based on the component's settings so that /// it only can rotate when a mouse button is pushed if that is specified. /// </summary> /// <param name="input"></param> private void EnforceRotationRestrictions(InputValues input) { if (!EnableRotationOnlyWhenMousePressed && !EnableRotationOnlyWhenCursorLocked) { return; } // Button isn't pushed, so null out rotation. if (EnableRotationOnlyWhenMousePressed && !Input.GetButton(MouseInputButtonName)) { input.Horizontal = null; input.Vertical = null; } // Cursor isn't locked, so null out rotation. else if (EnableRotationOnlyWhenCursorLocked && UnityEngine.Cursor.lockState == CursorLockMode.None) { input.Horizontal = null; input.Vertical = null; } }
/// <summary> /// Appends the Easy input to the current Input component. /// </summary> public void AppendInput() { if (!Enabled) { return; } InputValues input = GetEasyUnityInput(); EnforceRotationRestrictions(input); Enforce0NotNull(input); if (AppendOver) { _input.Input.ApplyOver(input); } else { _input.Input.ApplyUnder(input); } }
/// <summary> /// Multiplies all non-null values to the current input. /// </summary> /// <param name="input">The given input containing the values to multiply by.</param> public void MultiplyInput(InputValues input) { MultiplyInput(input.Horizontal, input.Vertical, input.ZoomIn, input.ZoomOut); }
/// <summary> /// Adds all non-null values to the current input. /// Null values on the current input become whatever the given input provides. /// </summary> /// <param name="input">Input you want to add.</param> public void AddInput(InputValues input) { AddInput(input.Horizontal, input.Vertical, input.ZoomIn, input.ZoomOut); }
/// <summary> /// Applies all non-null input properties in the given Input to the existing input. /// If appendOver is set to true, then all non-null values will replace any values currently existing. /// If appendOver is set to false, then all non-null values will only replace null values in the current input. /// </summary> /// <param name="horizontal">Input for horizontal.</param> /// <param name="vertical">Input for vertical.</param> /// <param name="zoomIn">Input for zooming in.</param> /// <param name="zoomOut">Input for zooming out.</param> /// <param name="appendOver">Appends these values over existing values.</param> public void AppendInput(float?horizontal, float?vertical, float?zoomIn, float?zoomOut, bool appendOver = true) { InputValues input = new InputValues(horizontal, vertical, zoomIn, zoomOut); AppendInput(input, appendOver); }
/// <summary> /// Clears the input values on the InputComponent. /// </summary> public void ClearInput() { Input = new InputValues(); }
/// <summary> /// Sets the input for the InputComponent. /// This completely overrides the current input replacing it. /// </summary> /// <param name="horizontal">Input for horizontal.</param> /// <param name="vertical">Input for vertical.</param> /// <param name="zoomIn">Input for zooming in.</param> /// <param name="zoomOut">Input for zooming out.</param> public void SetInput(float?horizontal, float?vertical, float?zoomIn, float?zoomOut) { InputValues input = new InputValues(horizontal, vertical, zoomIn, zoomOut); SetInput(input); }