Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved NullReferenceException within Unity.Netcode.Editor.CodeGen - anyone know how to fix it?

Discussion in 'Netcode for GameObjects' started by anglerge, May 27, 2022.

  1. anglerge

    anglerge

    Joined:
    Dec 18, 2020
    Posts:
    15
    I honestly have no idea how it started, but I've recently encountered a particularly nasty error within Netcode for GameObjects (1.0.0 pre 9), and it doesn't seem to be going away (even after reverting back to a version of my project from before this error started appearing, and several more hours of trial and error trying to work out what could be the cause of it and trying to get it to go away (reimporting all the assets, changing the installed version of Netcode for GameObjects, etc)).

    (0,0): error - System.NullReferenceException: Object reference not set to an instance of an object|| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process (Unity.CompilationPipeline.Common.ILPostProcessing.ICompiledAssembly compiledAssembly) [0x00161] in <c68a31db69ca400d86b2009bda4cd3b4>:0 at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process (Unity.CompilationPipeline.Common.ILPostProcessing.ICompiledAssembly compiledAssembly) [0x00161] in <c68a31db69ca400d86b2009bda4cd3b4>:0​

    So, before I completely lose my sanity over this, I figured that I should ask if anyone else encountered this specific problem, and if anyone else has any idea how to fix it (considering that the details of this error message are particularly unhelpful).

    edit: cancel that, found a fix (see reply)
     
    Last edited: May 30, 2022
  2. anglerge

    anglerge

    Joined:
    Dec 18, 2020
    Posts:
    15
    quick update: okay, looks like a NetworkBehaviour with a generic constraint (which I added on Thursday) appears to have been the cause of the compiler error which only reared its ugly head on Friday (seeing as removing that fixed the error).

    No idea how the error only decided to appear the day after I added that class (not complaining about it for the entire duration of Thursday), which is somewhat odd.
     
  3. alytvynenko

    alytvynenko

    Joined:
    Apr 11, 2022
    Posts:
    5
    @anglerge I have got the same error after updating netcode version. Could you tell me how to fix it?
     
  4. anglerge

    anglerge

    Joined:
    Dec 18, 2020
    Posts:
    15
    Which version are you currently using?
     
  5. alytvynenko

    alytvynenko

    Joined:
    Apr 11, 2022
    Posts:
    5
    I have made an bug report on github and it has already been fixed.
     
    RikuTheFuffs-U likes this.