A game about forced loneliness, made by TACStudios
1namespace UnityEngine.InputSystem.Processors
2{
3 /// <summary>
4 /// Scale the components of a <see cref="Vector2"/> by constant factors.
5 /// </summary>
6 /// <remarks>
7 /// This processor is registered (see <see cref="InputSystem.RegisterProcessor{T}"/>) under the name "scaleVector2".
8 ///
9 /// <example>
10 /// <code>
11 /// // Double the length of the vector produced by leftStick on gamepad.
12 /// myAction.AddBinding("<Gamepad>/leftStick").WithProcessor("scaleVector2(x=2,y=2)");
13 /// </code>
14 /// </example>
15 /// </remarks>
16 /// <seealso cref="ScaleProcessor"/>
17 /// <seealso cref="ScaleVector3Processor"/>
18 public class ScaleVector2Processor : InputProcessor<Vector2>
19 {
20 /// <summary>
21 /// Scale factor to apply to the vector's <c>x</c> axis. Defaults to 1.
22 /// </summary>
23 [Tooltip("Scale factor to multiply the incoming Vector2's X component by.")]
24 public float x = 1;
25
26 /// <summary>
27 /// Scale factor to apply to the vector's <c>y</c> axis. Defaults to 1.
28 /// </summary>
29 [Tooltip("Scale factor to multiply the incoming Vector2's Y component by.")]
30 public float y = 1;
31
32 /// <summary>
33 /// Return <paramref name="value"/> scaled by <see cref="x"/> and <see cref="y"/>.
34 /// </summary>
35 /// <param name="value">Input value.</param>
36 /// <param name="control">Ignored.</param>
37 /// <returns>Scaled vector.</returns>
38 public override Vector2 Process(Vector2 value, InputControl control)
39 {
40 return new Vector2(value.x * x, value.y * y);
41 }
42
43 /// <inheritdoc/>
44 public override string ToString()
45 {
46 return $"ScaleVector2(x={x},y={y})";
47 }
48 }
49}