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