Struct InputControlList<TControl> | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct InputControlList<TControl>

    Keep a list of InputControl without allocating managed memory.

    Inherited Members
    System.ValueType.Equals(System.Object)
    System.ValueType.GetHashCode()
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetType()
    Namespace: UnityEngine.Experimental.Input
    Syntax
    public struct InputControlList<TControl> : IList<TControl>, IReadOnlyList<TControl>, IDisposable where TControl : InputControl
    Type Parameters
    Name Description
    TControl
    Remarks

    Requires the control setup in the system to not change while the list is being used. If devices are removed from the system, the list will no be valid. Also, only works with controls of devices that have been added to the system (meaning that it cannot be used with devices created by before they have been AddDevice<TDevice>(String)).

    Allocates unmanaged memory. Must be disposed or will leak memory. By default allocates persistent memory. Can direct it to use another allocator with InputControlList<TControl>.

    Constructors

    InputControlList(TControl[])

    Declaration
    public InputControlList(params TControl[] values)
    Parameters
    Type Name Description
    TControl[] values

    InputControlList(Allocator, Int32)

    Construct a list that allocates unmanaged memory from the given allocator.

    Declaration
    public InputControlList(Allocator allocator, int initialCapacity = 0)
    Parameters
    Type Name Description
    Allocator allocator
    System.Int32 initialCapacity
    Examples
    // Create a control list that allocates from the temporary memory allocator.
    using (var list = new InputControlList(Allocator.Temp))
    {
        // Add all gamepads to the list.
        InputSystem.FindControls("<Gamepad>", list);
    }

    InputControlList(IEnumerable<TControl>, Allocator)

    Declaration
    public InputControlList(IEnumerable<TControl> values, Allocator allocator = null)
    Parameters
    Type Name Description
    IEnumerable<TControl> values
    Allocator allocator

    Properties

    Capacity

    Number of controls that can be added before more (unmanaged) memory has to be allocated.

    Declaration
    public int Capacity { get; set; }
    Property Value
    Type Description
    System.Int32

    Count

    Number of controls in the list.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    IsReadOnly

    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    System.Boolean

    Item[Int32]

    Return the control at the given index.

    Declaration
    public TControl this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index

    Index of control.

    Property Value
    Type Description
    TControl
    Remarks

    Internally, the list only stores indices. Resolution to InputControl happens dynamically by looking them up globally.

    Methods

    Add(TControl)

    Declaration
    public void Add(TControl control)
    Parameters
    Type Name Description
    TControl control

    AddRange(IEnumerable<TControl>, Int32, Int32)

    Declaration
    public void AddRange(IEnumerable<TControl> list, int count = -1, int destinationIndex = -1)
    Parameters
    Type Name Description
    IEnumerable<TControl> list
    System.Int32 count
    System.Int32 destinationIndex

    AddSlice<TList>(TList, Int32, Int32, Int32)

    Add a slice of elements taken from the given list.

    Declaration
    public void AddSlice<TList>(TList list, int count = -1, int destinationIndex = -1, int sourceIndex = 0)where TList : IReadOnlyList<TControl>
    Parameters
    Type Name Description
    TList list
    System.Int32 count
    System.Int32 destinationIndex
    System.Int32 sourceIndex
    Type Parameters
    Name Description
    TList

    Clear()

    Declaration
    public void Clear()

    Contains(TControl)

    Declaration
    public bool Contains(TControl control)
    Parameters
    Type Name Description
    TControl control
    Returns
    Type Description
    System.Boolean

    CopyTo(TControl[], Int32)

    Declaration
    public void CopyTo(TControl[] array, int arrayIndex)
    Parameters
    Type Name Description
    TControl[] array
    System.Int32 arrayIndex

    Dispose()

    Declaration
    public void Dispose()

    GetEnumerator()

    Declaration
    public IEnumerator<TControl> GetEnumerator()
    Returns
    Type Description
    IEnumerator<TControl>

    IndexOf(TControl)

    Declaration
    public int IndexOf(TControl control)
    Parameters
    Type Name Description
    TControl control
    Returns
    Type Description
    System.Int32

    Insert(Int32, TControl)

    Declaration
    public void Insert(int index, TControl item)
    Parameters
    Type Name Description
    System.Int32 index
    TControl item

    Remove(TControl)

    Declaration
    public bool Remove(TControl control)
    Parameters
    Type Name Description
    TControl control
    Returns
    Type Description
    System.Boolean

    RemoveAt(Int32)

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    Sort<TCompare>(Int32, Int32, TCompare)

    Declaration
    public void Sort<TCompare>(int startIndex, int count, TCompare comparer)where TCompare : IComparer<TControl>
    Parameters
    Type Name Description
    System.Int32 startIndex
    System.Int32 count
    TCompare comparer
    Type Parameters
    Name Description
    TCompare

    SwapElements(Int32, Int32)

    Declaration
    public void SwapElements(int index1, int index2)
    Parameters
    Type Name Description
    System.Int32 index1
    System.Int32 index2

    ToArray()

    Declaration
    public TControl[] ToArray()
    Returns
    Type Description
    TControl[]

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.ValueType.ToString()
    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