using System.Collections.Generic; namespace UnityEngine.InputSystem.Utilities { /// /// Compare two by magnitude. /// /// /// /// /// public class CompositeWithVector2Part : InputBindingComposite<Vector2> /// { /// [InputControl(layout = "Vector2")] /// public int part; /// /// public override Vector2 ReadValue(ref InputBindingCompositeContext context) /// { /// // Return the Vector3 with the greatest magnitude. /// return context.ReadValue<Vector2, Vector2MagnitudeComparer>(part); /// } /// } /// public struct Vector2MagnitudeComparer : IComparer { public int Compare(Vector2 x, Vector2 y) { var lenx = x.sqrMagnitude; var leny = y.sqrMagnitude; if (lenx < leny) return -1; if (lenx > leny) return 1; return 0; } } /// /// Compare two by magnitude. /// /// /// /// /// public class CompositeWithVector3Part : InputBindingComposite<Vector3> /// { /// [InputControl(layout = "Vector3")] /// public int part; /// /// public override Vector3 ReadValue(ref InputBindingCompositeContext context) /// { /// // Return the Vector3 with the greatest magnitude. /// return context.ReadValue<Vector3, Vector2MagnitudeComparer>(part); /// } /// } /// public struct Vector3MagnitudeComparer : IComparer { public int Compare(Vector3 x, Vector3 y) { var lenx = x.sqrMagnitude; var leny = y.sqrMagnitude; if (lenx < leny) return -1; if (lenx > leny) return 1; return 0; } } }