Method TryBeginReadValue
TryBeginReadValue<T>(in T)
Allows faster serialization by batching bounds checking. When you know you will be reading multiple fields back-to-back and you know the total size, you can call TryBeginRead() once on the total size, and then follow it with calls to ReadValue() instead of ReadValueSafe() for faster serialization.
Unsafe read operations will throw OverflowException in editor and development builds if you go past the point you've marked using TryBeginRead(). In release builds, OverflowException will not be thrown for performance reasons, since the point of using TryBeginRead is to avoid bounds checking in the following operations in release builds.
Declaration
public bool TryBeginReadValue<T>(in T value) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T | value | The value you want to read |
Returns
Type | Description |
---|---|
bool | True if the read is allowed, false otherwise |
Type Parameters
Name | Description |
---|---|
T | the type |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If called while in a bitwise context |