When crossing assemblies, you may not be able to obtain the Reader/Writer defined by yourself.
Describe the bug
ReaderWriterProcessor registers a custom Reader/Writer included in AssemblyReferences of CurrentAssembly.
However, in a complicated case, when a NetworkMessage contained in AssemblyReferences requires a Reader/Writer that is not contained in its CurrentAssembly.AssemblyReferences, Reader<T>.read contains the one generated with Readers.GenerateClassOrStructReadFunction() will be inserted.
[IMPORTANT] How can we reproduce the issue, step by step:
- Create assembly A. Here we define a simple record and a custom Reader/Writer. By using { get; set; },
Readers.GenerateClassOrStructReadFunction()will not insert a value, making it easier to test. - Create assembly B. Create a NetworkMessage here and set the record created in assembly A to the property.
- Create assembly C. References assembly B only. Write code that appropriately references NetworkMessage in C. Without this, it seems that it is not included in CurrentAssembly.AssemblyReferences.
- Create a new class in assembly B that inherits NetworkBehaviour. Add SyncList<record defined in assembly A> to the properties. The server adds a random value to the SyncList during Update, etc.
- Start two Unity app using PararelSync etc. and check the behavior on Server / Client. The Count of SyncList is increasing and the contents are also increasing, but the value received by the Client is always the initial value.
Expected behavior The value incremented by SyncList must be set correctly.
Desktop (please complete the following information):
- OS: Windows
- Build target: Windows
- Unity version: 2022.3.23f1
- Mirror branch: master
Additional context I fixed this issue locally. also ready to submit a PullRequest. If you don't mind, could you add me as a contributor?
Hey @pepoipod how did you fix this? You should be able to open a PR if you fork Mirror, create a branch with your change, push it, and then go to mirror -> pull requests, github will suggest you to open your branch as PR
@miwarnec Thanks for letting me know, I will create a Pull Request as soon as possible.
closing thanks to https://github.com/MirrorNetworking/Mirror/pull/3864