I need some customization on the NetworkManager Class for my game I'm working on. I've read, that it's pretty common to override stuff from the NetworkManager. So I've implemented the NetworkManager as CustomNetworkManager class like this :

using UnityEngine.Networking;

public class CustomNetworkManager : NetworkManager


I hope I'm right, that I don't have to implement a method to get all the functionality from the base class?

I duplicated my NetworkManager Object, which basically was just the NetworkManager with another CustomNetworking Script. Then I replaced the old NetworkManager with my new CustomNetworkManager and changed the references in the other script accordingly.

So my old GameObject looks like this :

enter image description here

And this is my new GameObject :

enter image description here

The old GameObject works (I just have to change the NetworkManager type in my CustomNetworking class)

But the new GameObject with the custom implementation is getting the following error :

NullReferenceException: Object reference not set to an instance of an object
CustomNetworking.EnableMatchmaker () (at Assets/CustomNetworking.cs:27)

The CustomNetworking class with the error looks like this :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
using UnityEngine.Networking.Types;

public class CustomNetworking : MonoBehaviour
    public CustomNetworkManager manager;
    public MatchInfo currentMatch;

    // Use this for initialization
    void Start()
        manager = GetComponent<CustomNetworkManager>();

    public void EnableMatchmaker()
        manager.StartMatchMaker(); //This is the first call which is made and where the error occurs

    public void CreateMatchmakerMatch()
            true, "", "", "", 0, 0,


    public void FindMatchmakerMatch()
        manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, manager.OnMatchList);

        if (manager.matches != null)
            for (int i = 0; i < manager.matches.Count; i++)
                var match = manager.matches[i];
                manager.matchName = match.name;
                manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, manager.OnMatchJoined);

    public void DestroyMatchmakerMatch()
        manager.matchMaker.DropConnection(manager.matchInfo.networkId, manager.matchInfo.nodeId, 0, manager.OnDropConnection);
        manager.matchMaker.DestroyMatch(manager.matchInfo.networkId, 0, manager.OnDestroyMatch);

    public void StartMatchmakerMatch()

I think I did some failure with implementing the overwritten NetworkManager, hopefully someone can help me with this issue.

  • \$\begingroup\$ Is the project set up correctly to use networking? Check this thread out: forum.unity3d.com/threads/… \$\endgroup\$ – John Hamilton Jan 30 '17 at 18:27
  • 1
    \$\begingroup\$ Yeah the old network manager does the job I was already able to play via LAN and Internet \$\endgroup\$ – TobiasW Jan 30 '17 at 18:29
  • \$\begingroup\$ What exact type is 'manager'? \$\endgroup\$ – Gnemlock Jan 30 '17 at 21:28
  • \$\begingroup\$ It's the NetworkManager script from Unet docs.unity3d.com/ScriptReference/Networking.NetworkManager.html \$\endgroup\$ – TobiasW Jan 30 '17 at 21:35
  • \$\begingroup\$ Can you post CustomNetworking.cs? \$\endgroup\$ – Mir Feb 1 '17 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.