docs.unity3d.com
    Show / Hide Table of Contents

    Class CommandDataUtility

    Contains utility methods to add and retrieve commands from ICommandData dynamic buffers.

    Inheritance
    Object
    CommandDataUtility
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.NetCode
    Syntax
    public static class CommandDataUtility

    Fields

    k_CommandDataMaxSize

    The maximum number of commands that can be sent in one single command packet.

    Declaration
    public const int k_CommandDataMaxSize = 64
    Field Value
    Type Description
    Int32

    Methods

    AddCommandData<T>(DynamicBuffer<T>, T)

    Add an instance of a ICommandData into the command circular buffer. The command buffer capacity if fixed and the Tick is used to find in which slot the command should be put to keep the command buffer sorted. If a command with the same tick already exists in the buffer, it will be overritten

    Declaration
    public static void AddCommandData<T>(this DynamicBuffer<T> commandArray, T commandData)
        where T : struct, ICommandData
    Parameters
    Type Name Description
    DynamicBuffer<T> commandArray
    T commandData
    Type Parameters
    Name Description
    T

    the command type

    GetDataAtTick<T>(DynamicBuffer<T>, NetworkTick, out T)

    Get latest command data for given target tick. For example, if command buffer contains ticks 3,4,5,6 and targetTick is 5 it will return tick 5 (latest without going over). If the command buffer is 1,2,3 and targetTick is 5 it will return tick 3.

    Declaration
    public static bool GetDataAtTick<T>(this DynamicBuffer<T> commandArray, NetworkTick targetTick, out T commandData)
        where T : struct, ICommandData
    Parameters
    Type Name Description
    DynamicBuffer<T> commandArray
    NetworkTick targetTick
    T commandData
    Returns
    Type Description
    Boolean

    Returns true if any data was found, false when no tick data is equal or older to the target tick in the buffer.

    Type Parameters
    Name Description
    T
    In This Article
    • Fields
      • k_CommandDataMaxSize
    • Methods
      • AddCommandData<T>(DynamicBuffer<T>, T)
      • GetDataAtTick<T>(DynamicBuffer<T>, NetworkTick, out T)
    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