Class AxisComposite | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class AxisComposite

    A single [-1..1] axis value computed from a "negative" and a "positive" button.

    Inheritance
    System.Object
    InputBindingComposite<System.Single>
    AxisComposite
    Inherited Members
    InputBindingComposite<Single>.valueType
    InputBindingComposite<Single>.valueSizeInBytes
    InputBindingComposite<Single>.ReadValue(InputBindingCompositeContext, Void*, Int32)
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UnityEngine.Experimental.Input.Composites
    Syntax
    public class AxisComposite : InputBindingComposite<float>, IInputBindingComposite<float>, IInputBindingComposite
    Remarks

    This composite allows to arrange any arbitrary two buttons from a device in an axis configuration such that one button pushes in one direction and the other pushes in the opposite direction.

    If both buttons are pressed at the same time, the behavior depends on whichSideWins. By default, neither side will win (Neither) and the result will be 0. This can be customized to make the positive side win (Positive) or the negative one (Negative).

    This is useful, for example, in a driving game where break should cancel out accelerate. By binding negative to the break control(s) and positive to the acceleration control(s), and setting whichSideWins to Negative, if the break button is pressed, it will always cause the acceleration button to be ignored.

    The values returned are the actual actuation values of the buttons, unaltered for positive and inverted for negative. This means that if the buttons are actual axes (e.g. the triggers on gamepads), then the values correspond to how much the axis is actuated.

    Fields

    negative

    Binding for the button that controls the positive direction of the axis.

    Declaration
    public int negative
    Field Value
    Type Description
    System.Int32

    positive

    Binding for the button that controls the negative direction of the axis.

    Declaration
    public int positive
    Field Value
    Type Description
    System.Int32

    whichSideWins

    If both the positive and negative button are actuated, this determines which value is returned from the composite.

    Declaration
    public AxisComposite.WhichSideWins whichSideWins
    Field Value
    Type Description
    AxisComposite.WhichSideWins

    Methods

    ReadValue(ref InputBindingCompositeContext)

    Declaration
    public override float ReadValue(ref InputBindingCompositeContext context)
    Parameters
    Type Name Description
    InputBindingCompositeContext context
    Returns
    Type Description
    System.Single
    Overrides
    UnityEngine.Experimental.Input.InputBindingComposite<System.Single>.ReadValue(UnityEngine.Experimental.Input.InputBindingCompositeContext)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023