Search Unity

When subscribing to NetworkManager.OnClientDisconnectCallback I get no message on local Shutdown()

Discussion in 'Netcode for GameObjects' started by qNaN, Apr 21, 2022.

  1. qNaN

    qNaN

    Joined:
    Dec 29, 2015
    Posts:
    26
    If I subscribe to the NetworkManager.OnClientDisconnectCallback I will get no message if I call NetworkManager.Shutdown() on my client, whether that is as a Host or a Client.

    Is the NetworkManager destroyed on the local machine before the event can be fired?
     
  2. unity_NTyxeB384OxNOQ

    unity_NTyxeB384OxNOQ

    Joined:
    Mar 5, 2019
    Posts:
    4
    This does seem to be the case.
    I used a function "LeaveLobby" that would fire in OnDestory() and after that (also in OnDestroy) ... i would remove the listener to the "OnClientDisconnectCallback" and it would throw a NullReference exception (telling me that your assumption is correct).
    Hope this helps :)