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> and/or <c>z</c> channel of a <c>Vector3</c>. 7 /// </summary> 8 /// <remarks> 9 /// This process is registered (see <see cref="InputSystem.RegisterProcessor{T}"/> as "invertVector3" by default. 10 /// 11 /// <example> 12 /// <code> 13 /// // Bind to gravity sensor such that its Y value is inverted. 14 /// new InputAction(binding: "&lt;GravitySensor&gt;/gravity", processors="invertVector3(invertX=false,invertY,invertZ=false)"); 15 /// </code> 16 /// </example> 17 /// </remarks> 18 /// <seealso cref="InvertVector2Processor"/> 19 public class InvertVector3Processor : InputProcessor<Vector3> 20 { 21 /// <summary> 22 /// If true, the <c>x</c> channel of the <c>Vector3</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>Vector3</c> input value is inverted. True by default. 28 /// </summary> 29 public bool invertY = true; 30 31 /// <summary> 32 /// If true, the <c>z</c> channel of the <c>Vector3</c> input value is inverted. True by default. 33 /// </summary> 34 public bool invertZ = true; 35 36 /// <summary> 37 /// Return the given vector with the respective channels being inverted. 38 /// </summary> 39 /// <param name="value">Input value.</param> 40 /// <param name="control">Ignored.</param> 41 /// <returns>Vector with channels inverted according to <see cref="invertX"/>, <see cref="invertY"/>, and <see cref="invertZ"/>.</returns> 42 public override Vector3 Process(Vector3 value, InputControl control) 43 { 44 if (invertX) 45 value.x *= -1; 46 if (invertY) 47 value.y *= -1; 48 if (invertZ) 49 value.z *= -1; 50 return value; 51 } 52 53 /// <inheritdoc/> 54 public override string ToString() 55 { 56 return $"InvertVector3(invertX={invertX},invertY={invertY},invertZ={invertZ})"; 57 } 58 } 59}