Using Generics with ServerRpc will generate error at line (0,0) #1860
Labels
stat:awaiting triage
Status - Awaiting triage from the Netcode team.
type:support
Questions or other support
Descripition
I was trying to make a handler that can sync variables over network, my only problem is that when I use a method with the ServerRpc attribute it gives my a compile error.
Reproduce Steps
Actual Outcome
This is the error i get:
(0,0): error - System.NullReferenceException: Object reference not set to an instance of an object.|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GetWriteMethodForParameter(TypeReference paramType, MethodReference& methodRef) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 621|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.InjectWriteAndCallBlocks(MethodDefinition methodDefinition, CustomAttribute rpcAttribute, UInt32 rpcMethodId) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 1014|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 409|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass5_0.<Process>b__1(TypeDefinition b) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 62|| at System.Collections.Generic.List
1.ForEach(Action1 action)|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 59 at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GetWriteMethodForParameter(TypeReference paramType, MethodReference& methodRef) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 621|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.InjectWriteAndCallBlocks(MethodDefinition methodDefinition, CustomAttribute rpcAttribute, UInt32 rpcMethodId) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 1014|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 409|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass5_0.<Process>b__1(TypeDefinition b) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 62|| at System.Collections.Generic.List
1.ForEach(Action1 action)|| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly) in D:\Unity Projects\FPS Multiplayer\Library\PackageCache\[email protected]\Editor\CodeGen\NetworkBehaviourILPP.cs:line 59
Expected Outcome
I expected unity wouldnt have given my any compile errors because i see no issues with what could go wrong at compile level. I was going to use this code to deploy on other scripts to be able to sync variables over network.
Environment
OS: Windows 10 Education
Unity Version: 2021.2.13f1
Netcode Version: 1.0.0-pre.6 - March 03, 2022
Additional Context
I suspect that a Rpc with generics is giving the error but my implentation of the code above would be like this , which would give it a hard type at compile time because of inheritance so I see no issue of my implemetation:
The text was updated successfully, but these errors were encountered: