Skip to content

NetworkedVar nullable type not supported #271

Description

@dosomder

Describe the bug
When using a nullable type for NetworkedVar, the following exception is thrown:

ArgumentException: BitReader cannot read type Nullable`1
MLAPI.Serialization.BitReader.ReadObjectPacked (System.Type type) (at <8d9fa217963146d0878ccfa52019c2fa>:0)
MLAPI.NetworkedVar.NetworkedVar`1[T].ReadDelta (System.IO.Stream stream, System.Boolean keepDirtyDelta) (at <8d9fa217963146d0878ccfa52019c2fa>:0)
MLAPI.NetworkedBehaviour.HandleNetworkedVarDeltas (System.Collections.Generic.List`1[T] networkedVarList, System.IO.Stream stream, System.UInt64 clientId, MLAPI.NetworkedBehaviour logInstance) (at <8d9fa217963146d0878ccfa52019c2fa>:0)
MLAPI.Messaging.InternalMessageHandler.HandleNetworkedVarDelta (System.UInt64 clientId, System.IO.Stream stream) (at <8d9fa217963146d0878ccfa52019c2fa>:0)
MLAPI.NetworkingManager.HandleIncomingData (System.UInt64 clientId, System.String channelName, System.ArraySegment`1[T] data, System.Single receiveTime) (at <8d9fa217963146d0878ccfa52019c2fa>:0)
MLAPI.NetworkingManager.Update () (at <8d9fa217963146d0878ccfa52019c2fa>:0)

Is it required to write a custom NetworkedVar container?

To Reproduce
Use a nullable type, e.g. (normal Vector3 object works)

private static NetworkedVarSettings defaultNetVarSettings = new NetworkedVarSettings()
    {
        ReadPermission = NetworkedVarPermission.Everyone,
        WritePermission = NetworkedVarPermission.OwnerOnly
    };

    private NetworkedVar<Vector3?> lookAtPos = new NetworkedVar<Vector3?>(defaultNetVarSettings);

Expected behavior
Variable is synchronized.

Environment (please complete the following information):

  • OS: [e.g. Windows 10]
  • Unity Version: 2019.1.6f1
  • MLAPI Version: 10.13.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions