Search Unity

ServerRpc not working when defined in assembly

Discussion in 'Multiplayer' started by Laumania, Mar 20, 2023.

  1. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    221
    Hey

    Is there a way to tell NGO some extra assemblies to look for [ServerRpc] in? I have the problem that the "Core" parts of my game is made in an assembly, external from Unity, so I can share that part as part of my Mod Tools.

    However, NetworkVariables works fine when used in that, but ServerRpc is not fired on the server, they are executed on the client it seems. Any idea as this is going to be a huge problem for me if not possible :S
     
  2. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    221
    Looked into the NetCode source and it seems like assemblies are passed to this method to get processed and this is where it look for ServerRpc attributes:
    class NetworkBehaviourILPP : ILPPInterface

    https://github.com/Unity-Technologi...ts/Editor/CodeGen/NetworkBehaviourILPP.cs#L29

    Code (CSharp):
    1. public override bool WillProcess(ICompiledAssembly compiledAssembly) => compiledAssembly.References.Any(filePath => Path.GetFileNameWithoutExtension(filePath) == CodeGenHelpers.RuntimeAssemblyName);
    Seems like this methods decide if an assembly should be processed, however my external assembly do reference the "Unity.NetCode.Runtime" so it should be included - assuming all assemblies are passed through here. I can't seem to debug this, so I don't know.

    It could also be that "ICompiledAssembly" is actually AssemblyDefinitions from Unity, which my .dll is not for obvious reasons.

    Hmm... any help would be appreciated :)