A game about forced loneliness, made by TACStudios
1using UnityEngine.Scripting;
2
3namespace UnityEngine.InputSystem.Processors
4{
5 /// <summary>
6 /// Inverts the <c>x</c> and/or <c>y</c> channel of a <c>Vector2</c>.
7 /// </summary>
8 /// <remarks>
9 /// This process is registered (see <see cref="InputSystem.RegisterProcessor{T}"/> as "invertVector2" by default.
10 ///
11 /// <example>
12 /// <code>
13 /// // Bind to the left stick on the gamepad such that its Y channel is inverted.
14 /// new InputAction(binding: "<Gamepad>/leftStick", processors="invertVector2(invertY,invertX=false)");
15 /// </code>
16 /// </example>
17 /// </remarks>
18 /// <seealso cref="InvertVector3Processor"/>
19 public class InvertVector2Processor : InputProcessor<Vector2>
20 {
21 /// <summary>
22 /// If true, the <c>x</c> channel of the <c>Vector2</c> input value is inverted. True by default.
23 /// </summary>
24 public bool invertX = true;
25
26 /// <summary>
27 /// If true, the <c>y</c> channel of the <c>Vector2</c> input value is inverted. True by default.
28 /// </summary>
29 public bool invertY = true;
30
31 /// <summary>
32 /// Invert the <c>x</c> and/or <c>y</c> channel of the given <paramref name="value"/>.
33 /// </summary>
34 /// <param name="value">Input value.</param>
35 /// <param name="control">Ignored.</param>
36 /// <returns>Vector2 with inverted channels.</returns>
37 public override Vector2 Process(Vector2 value, InputControl control)
38 {
39 if (invertX)
40 value.x *= -1;
41 if (invertY)
42 value.y *= -1;
43 return value;
44 }
45
46 /// <inheritdoc/>
47 public override string ToString()
48 {
49 return $"InvertVector2(invertX={invertX},invertY={invertY})";
50 }
51 }
52}