docs.unity3d.com
    Show / Hide Table of Contents

    Class Vector3Composite

    A 3D vector formed from six floating-point inputs.

    Inheritance
    Object
    InputBindingComposite
    InputBindingComposite<Vector3>
    Vector3Composite
    Inherited Members
    InputBindingComposite<Vector3>.valueType
    InputBindingComposite<Vector3>.valueSizeInBytes
    InputBindingComposite<Vector3>.ReadValue(InputBindingCompositeContext, Void*, Int32)
    InputBindingComposite<Vector3>.ReadValueAsObject(InputBindingCompositeContext)
    InputBindingComposite.EvaluateMagnitude(InputBindingCompositeContext)
    InputBindingComposite.FinishSetup(InputBindingCompositeContext)
    InputBindingComposite.GetExpectedControlLayoutName(String, String)
    Namespace: UnityEngine.InputSystem.Composites
    Syntax
    public class Vector3Composite : InputBindingComposite<Vector3>
    Remarks

    Depending on the setting of mode, the vector is either in the [-1..1] range on each axis (normalized or not depending on mode) or is in the full value range of the input controls.

    action.AddCompositeBinding("3DVector")
        .With("Forward", "<Keyboard>/w")
        .With("Backward", "<Keyboard>/s")
        .With("Left", "<Keyboard>/a")
        .With("Right", "<Keyboard>/d")
        .With("Up", "<Keyboard>/q")
        .With("Down", "<Keyboard>/e");

    Fields

    backward

    Binding for the button that represents the right (that is, (0,0,-1)) direction of the vector.

    Declaration
    public int backward
    Field Value
    Type Description
    Int32
    Remarks

    This property is automatically assigned by the input system.

    down

    Binding for the button that represents the down (that is, (0,-1,0)) direction of the vector.

    Declaration
    public int down
    Field Value
    Type Description
    Int32
    Remarks

    This property is automatically assigned by the input system.

    forward

    Binding for the button that represents the right (that is, (0,0,1)) direction of the vector.

    Declaration
    public int forward
    Field Value
    Type Description
    Int32
    Remarks

    This property is automatically assigned by the input system.

    left

    Binding for the button that represents the left (that is, (-1,0,0)) direction of the vector.

    Declaration
    public int left
    Field Value
    Type Description
    Int32
    Remarks

    This property is automatically assigned by the input system.

    mode

    How to synthesize a Vector3 from the values read from up, down, left, right, forward, and backward.

    Declaration
    public Vector3Composite.Mode mode
    Field Value
    Type Description
    Vector3Composite.Mode

    Determines how X, Y, and Z of the resulting Vector3 are formed from input values.

    right

    Binding for the button that represents the right (that is, (1,0,0)) direction of the vector.

    Declaration
    public int right
    Field Value
    Type Description
    Int32
    Remarks

    This property is automatically assigned by the input system.

    up

    Binding for the button that represents the up (that is, (0,1,0)) direction of the vector.

    Declaration
    public int up
    Field Value
    Type Description
    Int32
    Remarks

    This property is automatically assigned by the input system.

    Methods

    ReadValue(ref InputBindingCompositeContext)

    Read a value for the composite given the supplied context.

    Declaration
    public override Vector3 ReadValue(ref InputBindingCompositeContext context)
    Parameters
    Type Name Description
    InputBindingCompositeContext context

    Callback context for the binding composite. Use this to access the values supplied by part bindings.

    Returns
    Type Description
    Vector3

    The current value of the composite according to the state made accessible through context.

    Overrides
    UnityEngine.InputSystem.InputBindingComposite<Vector3>.ReadValue(UnityEngine.InputSystem.InputBindingCompositeContext)
    Remarks

    This is the main method to implement in custom composites.

    public class CustomComposite : InputBindingComposite<float>
    {
        [InputControl(layout = "Button")]
        public int button;
    
        public float scaleFactor = 1;
    
        public override float ReadValue(ref InputBindingComposite context)
        {
            return context.ReadValue<float>(button) * scaleFactor;
        }
    }

    The other method to consider overriding is EvaluateMagnitude(ref InputBindingCompositeContext).

    See Also
    ReadValue<TValue>()
    ReadValue<TValue>()

    See Also

    Vector2Composite
    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