Unity Networking and UI

I am currently delving into the new Networking functionality in Unity 5.x and I ran into a small problem.

I have a simple script on my Network Manager object similar to the Network Manager HUD, but using the new UI system, with two buttons to host or join a game. I have a Menu scene and a Game scene, both setup in the respective slots of my Network Manager.

The buttons work as expected, when I start the game, but when I am returned to the offline scene, after the hosts shuts down, the connection between the buttons and the script is broken.

Any idea how to fix this?

Edit: Putting my script on a different object and getting the NetworkManager component via ‘FindObjectOfType()’ fixes the connection with the buttons, but breaks something else.

I hacked together a solution, that I don’t particular like, but it works. If someone has a better solution, I’d still be glad to hear it.

I added this script to the canvas, to create the button connection on runtime.

    ConnectionManager _conMan;
    [SerializeField]
    Button _joinButton;

    [SerializeField]
    Button _hostButton;

    void Start () {
        _conMan = GameObject.Find("NetMan").GetComponent<ConnectionManager>();

        _joinButton.onClick.AddListener(() => _conMan.JoinGame());
        _hostButton.onClick.AddListener(() => _conMan.HostGame());
    }