com.unity.netcode.gameobjects@1.0.0
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0] - 2022-06-27 ### Changed - Changed version to 1.0.0. (#2046)
This commit is contained in:
@@ -6,6 +6,12 @@ using UnityEngine;
|
||||
|
||||
namespace Unity.Netcode
|
||||
{
|
||||
/// <summary>
|
||||
/// Optimized class used for reading values from a byte stream
|
||||
/// <seealso cref="FastBufferWriter"/>
|
||||
/// <seealso cref="BytePacker"/>
|
||||
/// <seealso cref="ByteUnpacker"/>
|
||||
/// </summary>
|
||||
public struct FastBufferReader : IDisposable
|
||||
{
|
||||
internal struct ReaderHandle
|
||||
@@ -87,15 +93,15 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// Create a FastBufferReader from a NativeArray.
|
||||
///
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"> and the value will be copied in.
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"></param> and the value will be copied in.
|
||||
/// FastBufferReader will then own the data.
|
||||
///
|
||||
/// The exception to this is when the <param name="copyAllocator"> passed in is Allocator.None. In this scenario,
|
||||
/// The exception to this is when the <param name="copyAllocator"></param> passed in is Allocator.None. In this scenario,
|
||||
/// ownership of the data remains with the caller and the reader will point at it directly.
|
||||
/// When created with Allocator.None, FastBufferReader will allocate some internal data using
|
||||
/// Allocator.Temp so it should be treated as if it's a ref struct and not allowed to outlive
|
||||
/// the context in which it was created (it should neither be returned from that function nor
|
||||
/// stored anywhere in heap memory). This is true, unless the <param name="internalAllocator"> param is explicitly set
|
||||
/// stored anywhere in heap memory). This is true, unless the <param name="internalAllocator"></param> param is explicitly set
|
||||
/// to i.e.: Allocator.Persistent in which case it would allow the internal data to Persist for longer, but the caller
|
||||
/// should manually call Dispose() when it is no longer needed.
|
||||
/// </summary>
|
||||
@@ -162,15 +168,15 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// Create a FastBufferReader from an existing byte buffer.
|
||||
///
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"> and the value will be copied in.
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"></param> and the value will be copied in.
|
||||
/// FastBufferReader will then own the data.
|
||||
///
|
||||
/// The exception to this is when the <param name="copyAllocator"> passed in is Allocator.None. In this scenario,
|
||||
/// The exception to this is when the <param name="copyAllocator"></param> passed in is Allocator.None. In this scenario,
|
||||
/// ownership of the data remains with the caller and the reader will point at it directly.
|
||||
/// When created with Allocator.None, FastBufferReader will allocate some internal data using
|
||||
/// Allocator.Temp, so it should be treated as if it's a ref struct and not allowed to outlive
|
||||
/// the context in which it was created (it should neither be returned from that function nor
|
||||
/// stored anywhere in heap memory). This is true, unless the <param name="internalAllocator"> param is explicitly set
|
||||
/// stored anywhere in heap memory). This is true, unless the <param name="internalAllocator"></param> param is explicitly set
|
||||
/// to i.e.: Allocator.Persistent in which case it would allow the internal data to Persist for longer, but the caller
|
||||
/// should manually call Dispose() when it is no longer needed.
|
||||
/// </summary>
|
||||
@@ -187,15 +193,15 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// Create a FastBufferReader from a FastBufferWriter.
|
||||
///
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"> and the value will be copied in.
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"></param> and the value will be copied in.
|
||||
/// FastBufferReader will then own the data.
|
||||
///
|
||||
/// The exception to this is when the <param name="copyAllocator"> passed in is Allocator.None. In this scenario,
|
||||
/// The exception to this is when the <param name="copyAllocator"></param> passed in is Allocator.None. In this scenario,
|
||||
/// ownership of the data remains with the caller and the reader will point at it directly.
|
||||
/// When created with Allocator.None, FastBufferReader will allocate some internal data using
|
||||
/// Allocator.Temp, so it should be treated as if it's a ref struct and not allowed to outlive
|
||||
/// the context in which it was created (it should neither be returned from that function nor
|
||||
/// stored anywhere in heap memory). This is true, unless the <param name="internalAllocator"> param is explicitly set
|
||||
/// stored anywhere in heap memory). This is true, unless the <param name="internalAllocator"></param> param is explicitly set
|
||||
/// to i.e.: Allocator.Persistent in which case it would allow the internal data to Persist for longer, but the caller
|
||||
/// should manually call Dispose() when it is no longer needed.
|
||||
/// </summary>
|
||||
@@ -214,10 +220,10 @@ namespace Unity.Netcode
|
||||
/// want to change the copyAllocator that a reader is allocated to - for example, upgrading a Temp reader to
|
||||
/// a Persistent one to be processed later.
|
||||
///
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"> and the value will be copied in.
|
||||
/// A new buffer will be created using the given <param name="copyAllocator"></param> and the value will be copied in.
|
||||
/// FastBufferReader will then own the data.
|
||||
///
|
||||
/// The exception to this is when the <param name="copyAllocator"> passed in is Allocator.None. In this scenario,
|
||||
/// The exception to this is when the <param name="copyAllocator"></param> passed in is Allocator.None. In this scenario,
|
||||
/// ownership of the data remains with the caller and the reader will point at it directly.
|
||||
/// When created with Allocator.None, FastBufferReader will allocate some internal data using
|
||||
/// Allocator.Temp, so it should be treated as if it's a ref struct and not allowed to outlive
|
||||
@@ -235,7 +241,7 @@ namespace Unity.Netcode
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Frees the allocated buffer
|
||||
/// <see cref="IDisposable"/> implementation that frees the allocated buffer
|
||||
/// </summary>
|
||||
public unsafe void Dispose()
|
||||
{
|
||||
@@ -335,6 +341,7 @@ namespace Unity.Netcode
|
||||
/// for performance reasons, since the point of using TryBeginRead is to avoid bounds checking in the following
|
||||
/// operations in release builds.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">the type `T` of the value you are trying to read</typeparam>
|
||||
/// <param name="value">The value you want to read</param>
|
||||
/// <returns>True if the read is allowed, false otherwise</returns>
|
||||
/// <exception cref="InvalidOperationException">If called while in a bitwise context</exception>
|
||||
@@ -364,7 +371,7 @@ namespace Unity.Netcode
|
||||
/// Differs from TryBeginRead only in that it won't ever move the AllowedReadMark backward.
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns></returns>
|
||||
/// <returns>true upon success</returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe bool TryBeginReadInternal(int bytes)
|
||||
@@ -393,7 +400,7 @@ namespace Unity.Netcode
|
||||
/// Returns an array representation of the underlying byte buffer.
|
||||
/// !!Allocates a new array!!
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>byte array</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe byte[] ToArray()
|
||||
{
|
||||
@@ -408,7 +415,7 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// Gets a direct pointer to the underlying buffer
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns><see cref="byte"/> pointer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe byte* GetUnsafePtr()
|
||||
{
|
||||
@@ -418,7 +425,7 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// Gets a direct pointer to the underlying buffer at the current read position
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns><see cref="byte"/> pointer</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe byte* GetUnsafePtrAtCurrentPosition()
|
||||
{
|
||||
@@ -428,8 +435,8 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// Read an INetworkSerializable
|
||||
/// </summary>
|
||||
/// <param name="value">INetworkSerializable instance</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value">INetworkSerializable instance</param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void ReadNetworkSerializable<T>(out T value) where T : INetworkSerializable, new()
|
||||
{
|
||||
@@ -442,7 +449,7 @@ namespace Unity.Netcode
|
||||
/// Read an array of INetworkSerializables
|
||||
/// </summary>
|
||||
/// <param name="value">INetworkSerializable instance</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T">the array to read the values of type `T` into</typeparam>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void ReadNetworkSerializable<T>(out T[] value) where T : INetworkSerializable, new()
|
||||
{
|
||||
@@ -537,7 +544,7 @@ namespace Unity.Netcode
|
||||
/// <param name="value">Value to read</param>
|
||||
/// <param name="bytesToRead">Number of bytes</param>
|
||||
/// <param name="offsetBytes">Offset into the value to write the bytes</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T">the type value to read the value into</typeparam>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
/// <exception cref="OverflowException"></exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -738,127 +745,522 @@ namespace Unity.Netcode
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a NetworkSerializable value
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable, new() => ReadNetworkSerializable(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a NetworkSerializable array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T[] value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable, new() => ReadNetworkSerializable(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a NetworkSerializable value
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable, new() => ReadNetworkSerializable(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a NetworkSerializable array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T[] value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable, new() => ReadNetworkSerializable(out value);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read a struct
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a struct array
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T[] value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a struct
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a struct array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T[] value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a primitive value (int, bool, etc)
|
||||
/// Accepts any value that implements the given interfaces, but is not guaranteed to work correctly
|
||||
/// on values that are not primitives.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T> => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a primitive value array (int, bool, etc)
|
||||
/// Accepts any value that implements the given interfaces, but is not guaranteed to work correctly
|
||||
/// on values that are not primitives.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T[] value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T> => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a primitive value (int, bool, etc)
|
||||
/// Accepts any value that implements the given interfaces, but is not guaranteed to work correctly
|
||||
/// on values that are not primitives.
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T> => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a primitive value (int, bool, etc)
|
||||
/// Accepts any value that implements the given interfaces, but is not guaranteed to work correctly
|
||||
/// on values that are not primitives.
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T[] value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T> => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read an enum value
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read an enum array
|
||||
/// </summary>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue<T>(out T[] value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum => ReadUnmanaged(out value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
/// <summary>
|
||||
/// Read an enum value
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum => ReadUnmanagedSafe(out value);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
/// <summary>
|
||||
/// Read an enum array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
/// <param name="value">The values to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe<T>(out T[] value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector2 value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2 array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector2[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector3 value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3 array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector3[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2Int
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector2Int value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2Int array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector2Int[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3Int
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector3Int value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3Int array
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector3Int[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector4
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector4 value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector4
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Vector4[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Quaternion
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Quaternion value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Quaternion array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Quaternion[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Color value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Color[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color32
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Color32 value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color32 array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Color32[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Ray value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Ray[] value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray2D
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Ray2D value) => ReadUnmanaged(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray2D array
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValue(out Ray2D[] value) => ReadUnmanaged(out value);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector2 value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2 array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector2[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector3 value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3 array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector3[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2Int
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector2Int value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector2Int array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector2Int[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3Int
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector3Int value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector3Int array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector3Int[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector4
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector4 value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Vector4 array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Vector4[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Quaternion
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Quaternion value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Quaternion array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Quaternion[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Color value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Collor array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Color[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color32
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Color32 value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Color32 array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Color32[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Ray value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Ray[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray2D
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Ray2D value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
/// <summary>
|
||||
/// Read a Ray2D array
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the values to read</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadValueSafe(out Ray2D[] value) => ReadUnmanagedSafe(out value);
|
||||
|
||||
@@ -868,6 +1270,17 @@ namespace Unity.Netcode
|
||||
// Those two are necessary to serialize FixedStrings efficiently
|
||||
// - otherwise we'd just be memcpying the whole thing even if
|
||||
// most of it isn't used.
|
||||
|
||||
/// <summary>
|
||||
/// Read a FixedString value.
|
||||
/// This method is a little difficult to use, since you have to know the size of the string before
|
||||
/// reading it, but is useful when the string is a known, fixed size. Note that the size of the
|
||||
/// string is also encoded, so the size to call TryBeginRead on is actually the fixed size (in bytes)
|
||||
/// plus sizeof(int)
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void ReadValue<T>(out T value, FastBufferWriter.ForFixedStrings unused = default)
|
||||
where T : unmanaged, INativeList<byte>, IUTF8Bytes
|
||||
@@ -878,6 +1291,16 @@ namespace Unity.Netcode
|
||||
ReadBytes(value.GetUnsafePtr(), length);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read a FixedString value.
|
||||
///
|
||||
/// "Safe" version - automatically performs bounds checking. Less efficient than bounds checking
|
||||
/// for multiple reads at once by calling TryBeginRead.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to read</param>
|
||||
/// <param name="unused">An unused parameter used for enabling overload resolution based on generic constraints</param>
|
||||
/// <typeparam name="T">The type being serialized</typeparam>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void ReadValueSafe<T>(out T value, FastBufferWriter.ForFixedStrings unused = default)
|
||||
where T : unmanaged, INativeList<byte>, IUTF8Bytes
|
||||
|
||||
Reference in New Issue
Block a user