Skip to content

Using Custom INetworkSerializable from an imported assembly causes Unity compilation error #672

Closed
@jmguillemette

Description

@jmguillemette

Describe the bug
-When using a custom struct that implements INetworkSerializable, if the struct is located in a different assembly than the RPC code that uses it then a compilation error is thrown by unity's compiler.

To Reproduce
Steps to reproduce the behavior:

  1. create an assembly called game.network
  2. create an assembly called game.player
  3. configure the game.player assembly to import the game.network assembly
  4. in the game.network assembly create a struct called playerInput and implement INetworkSerializable
  5. in the game.player assembly create a NetworkMonobehiour that include an ServerRCP method that takes in a PlayerInput struct as its input parameter.
  6. Unity will now recompile and error with a message similar to:

"(0,0): error System.ArgumentException: Member 'System.Void TreasureDungeon.Lib.Network.PlayerInputPacket::NetworkSerialize(MLAPI.Serialization.NetworkSerializer)' is declared in another module and needs to be imported"

The assemblies are properly defined and have the correct imports.

6, move the playerInput struct into the same assembly as the monobehaviour and the error goes away . Unity will compile the code.

Note: with the code separated by assemblies the code compiles just fine outside of unity. The assembly dependencies are properly declared.

Expected behavior
Separating the code into separate assemblies should not cause compile errors in unity.

Screenshots
If applicable, add screenshots to help explain your problem.

image

image

image

Environment (please complete the following information):

  • OS: WIN10
  • Unity Version: 2020.3.1f1
  • MLAPI Version: 0.1.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions