Search Unity

(0,0): error - System.NullReferenceException: Object reference not set to an instance of an object.

Discussion in 'Multiplayer' started by remzisch, Jun 11, 2022.

  1. remzisch

    remzisch

    Joined:
    May 30, 2022
    Posts:
    3
    hello I've been fighting with this exception for days. I've also started with the version change for gameobject from com.unity.netcode.gameobjects@1.0.0-pre.9 to com.unity.netcode.gameobjects@1.0.0-pre.8, com.unity.netcode.gameobjects@1.0 .0-pre.7 and at com.unity.netcode.gameobjects@1.0.0-pre.9 I get other exception... does anyone else have this?

    (0,0): error - System.NullReferenceException: Object reference not set to an instance of an object.| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) in /Users/remziemyumyunova/Multiplayer/Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Editor/CodeGen/INetworkSerializableILPP.cs:line 116 at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) in /Users/remziemyumyunova/Multiplayer/Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Editor/CodeGen/INetworkSerializableILPP.cs:line 116

    I use this video as a source:
    he is using 1.0.0.pre3 ...
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    666
    I've not seen it myself (still on pre7) but there's posts here and here, and a Github issue raised here.
     
  3. remzisch

    remzisch

    Joined:
    May 30, 2022
    Posts:
    3
    Hello, I have already seen these forum entries and unfortunately they did not help me...
     
  4. viknesh2020

    viknesh2020

    Joined:
    Jul 19, 2016
    Posts:
    52
    I am facing the same issue. I am trying to fix it on my own with a bypass to the reference or something like that. let's see if that helps. If yes, I will post the workaround here.
     
  5. KeithAM

    KeithAM

    Joined:
    Dec 23, 2013
    Posts:
    2
    I had the same issue. I made a "NetSingleton" for NetworkBehaviors. I removed any inheritance to it but the error was still there. It wasn't until I deleted the script that the error went away.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public abstract class NetSingleton<T> : NetworkBehaviour where T : NetSingleton<T>
    4. {
    5.     public static T Instance { get; protected set; }
    6.    
    7.     public static bool InstanceExists => Instance != null;
    8.  
    9.     public static bool TryGetInstance(out T result)
    10.     {
    11.         result = Instance;
    12.  
    13.         return result != null;
    14.     }
    15.  
    16.     protected virtual void Awake()
    17.     {
    18.         if (Instance != null)
    19.         {
    20.             Debug.LogWarningFormat("Trying to create a second instance of {0}", typeof(T));
    21.             Destroy(gameObject);
    22.         }
    23.         else
    24.         {
    25.             Instance = (T)this;
    26.             DontDestroyOnLoad(gameObject);
    27.         }
    28.     }
    29.  
    30.     new protected virtual void OnDestroy()
    31.     {
    32.         if (Instance == this)
    33.         {
    34.             Instance = null;
    35.         }
    36.         base.OnDestroy();
    37.     }
    38. }
     
  6. wechat_os_Qy05ZKxUfWmRbgFup9T3JaDtY

    wechat_os_Qy05ZKxUfWmRbgFup9T3JaDtY

    Joined:
    Jun 19, 2022
    Posts:
    1
    The latest Photon SDK must be Unity version 2021.3 or later to be able to do this. When you encounter this pitfall, earlier versions of Unity will report various errors
     
  7. viknesh2020

    viknesh2020

    Joined:
    Jul 19, 2016
    Posts:
    52
    The issue exists only when I create a generic type singleton with a NetworkBehaviour. If you change the NetworkBehaviour to MonoBehaviour, the error won't pop up.
     
    JudyBootyStudios likes this.