Closed brainwipe closed 2 years ago
Hi @brainwipe thanks for reporting. We will take a look and consider making them public if they don't cause any issues Or fix the documentation.
Backlog MTT-4261
Hi Rob Lang,
There has been some changes to those interfaces, which may have contributed to the confusion. The usage you are describing is not the intended one. We are just about to release 1.1
. What I'll describe below applies to both 1.1
, and current develop
branch.
If you want to simply create a NetworkVariable
of some new type, please use NetworkVariable<SomeNewType>
. The requirement is that SomeNewType
implements INetworkSerializable
(or is blittable). As long as this holds, internally, the correct serialization will happen. For new types, you'll need to implement the interface yourself.
If you rather want to create a new type of network container, please derive your container from NetworkVariableBase
. Then, you can implement WriteDelta
, ReadDelta
, WriteField
and ReadField
using FastBufferWriter
and FastBufferReader
:
public override void WriteDelta(FastBufferWriter writer)
{
writer.WriteValueSafe((ushort)1); // example, write the real data to serialize
}
Please feel free to re-open this issue, if the above explanation doesn't meet your needs.
Thanks, Jeff.
Description
Documentation implies that you can create your own custom network variable structures such as NetworkDictionary in the community package:
However, you cannot override Write and Read in
NetworkVariableSerialization<T>
because the methods are marked asinternal
.https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/98d190e70932f95d87a0679ac4278b0e393bd403/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs#L238
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/98d190e70932f95d87a0679ac4278b0e393bd403/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs#L243
I would expect these to be
public
orprotected
.Environment