question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProfilerCountersInfo.cs - NullReferenceException on NetworkManager.Start[...]()

See original GitHub issue

I’m seeing a NullReferenceException when starting my NetworkManager with the following script. Replicable with any of the three start methods. Strangely everything still works and I can move a character on the host and see it move on the clients.

Versions:

Unity 2021.1.7f1
MLAPI 0.1.0

Script:

using MLAPI;

public class AutoStartNetworkClone : NetworkBehaviour
{
  private NetworkManager netManager;
  void Start()
  {
    netManager = GetComponentInParent<NetworkManager>();

    netManager.StartClient();
  }
}

Error:

NullReferenceException: Object reference not set to an instance of an object
MLAPI.Profiling.ProfilerCountersInfo.OnPerformanceTickData (MLAPI.Profiling.PerformanceTickData tickData) (at Library/PackageCache/com.unity.multiplayer.mlapi@0.1.0/Runtime/Profiling/ProfilerCountersInfo.cs:79)
MLAPI.NetworkManager.OnNetworkPreUpdate () (at Library/PackageCache/com.unity.multiplayer.mlapi@0.1.0/Runtime/Core/NetworkManager.cs:760)
MLAPI.NetworkManager.NetworkUpdate (MLAPI.NetworkUpdateStage updateStage) (at Library/PackageCache/com.unity.multiplayer.mlapi@0.1.0/Runtime/Core/NetworkManager.cs:635)
MLAPI.NetworkUpdateLoop.RunNetworkUpdateStage (MLAPI.NetworkUpdateStage updateStage) (at Library/PackageCache/com.unity.multiplayer.mlapi@0.1.0/Runtime/Core/NetworkUpdateLoop.cs:149)
MLAPI.NetworkUpdateLoop+NetworkPreUpdate+<>c.<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.multiplayer.mlapi@0.1.0/Runtime/Core/NetworkUpdateLoop.cs:196)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LukeStampflicommented, Jun 2, 2021

It looks like for some reason it didn’t update your package cache. Try deleting the Library/PackageCache/com.unity.multiplayer.mlapi folder, then remove MLAPI from the manifest.json in the Packages folder and finally add it again using the link I posted above. That should work.

0reactions
fghlcommented, Jun 2, 2021

@LukeStampfli amazing, that worked perfectly. Appreciate you taking the time to answer!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullReferenceException on NetworkManager.Start[...]()
I'm seeing a NullReferenceException when starting my NetworkManager with the following script. Replicable with any of the three start ...
Read more >
Netcode.Singleton Always Returns NullReferenceException
I tried programming a series of code using Netcode. However, trying to call NetworkManager.Singleton.StartHost(); , NetworkManager.
Read more >
NullReferenceException when trying to start server or host ...
A small bug I encountered - when using the network manager HUD, if I start a client and then cancel and try to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found