Search Unity

Resolved NetworkManager Scene load not working for all clients

Discussion in 'Netcode for GameObjects' started by MidniteOil, Apr 23, 2023.

  1. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    Edit: Resolved this. Somehow, when changing the platform from Windows to iOS, the project ID got unlinked. Relinking the project fixed the issue.

    I have a cross-platform game (iOS, Windows Desktop) using Netcode for GameObjects, Lobby and Relay, if I create a game (doesn't matter which platform is the host) when I start the game and host changes scenes using the following code:;
    Code (CSharp):
    1.         using (new ShowMessageDialog("Starting the game..."))
    2.         {
    3.             try
    4.             {
    5.                 await MatchmakingService.LockLobby();
    6.                 MatchmakingService.UpdateLobbyGameState(GameState.Starting);
    7.                 NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnectedCallback;
    8.                 NetworkManager.Singleton.OnClientDisconnectCallback -= OnClientDisconnectCallback;
    9.                 NetworkManager.Singleton.SceneManager.LoadScene("Game", LoadSceneMode.Single);
    10.             }
    11.             catch (Exception e)
    12.             {
    13.                 Debug.Log($"Error in OnGameStarted(). {e}");
    14.             }
    15.         }
    The client on the other platform doesn't change to the new scene. This works fine if all the clients are running on Windows (haven't tried multiple iOS clients yet).

    Any ideas on why that would be?

    *edit: Not sure if this is related:
     
    Last edited: May 15, 2023
  2. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    If I run the iOS project in the editor it works. So something about targeting different platforms is breaking it.
     
  3. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    Here some more diagnostic info. I have verified via logging that I am definitely configuring the relay with the same ip/port on both platforms:
    upload_2023-4-27_10-47-13.png

    upload_2023-4-27_10-47-2.png
     
  4. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    I've also confirmed that I am not getting the OnClientConnectedCallback() on the host when a client starts.
     
  5. DenninDalke-Unity

    DenninDalke-Unity

    Unity Technologies

    Joined:
    Jun 2, 2022
    Posts:
    2
    This seems likely to be a managed code-stripping issue, we are aware of an issue in the multiplayer tools that could cause this issue, and we'll soon release a fix for it, but in the meantime, you can test one of these 3 potential solutions:

    - Remove the Multiplayer Tools package (com.unity.multiplayer.tools).

    - Or set the Managed Stripping Level to "disabled" (or verify other low values).

    - Or add the following XML into a file called "link.xml" in the Assets folder of your project (if you already have a link.xml in your project, please combine the entries so then you have one single and unified link.xml file). For more information on that, please check this section.

    Code (CSharp):
    1. <linker>
    2.     <assembly fullname="Unity.Netcode.Runtime" preserve="all"/>
    3.     <assembly fullname="Unity.Netcode.Components" preserve="all"/>
    4.     <assembly fullname="Unity.Multiplayer.Tools.Common" preserve="all"/>
    5.     <assembly fullname="Unity.Multiplayer.Tools.MetricTypes" preserve="all"/>
    6.     <assembly fullname="Unity.Multiplayer.Tools.NetStats" preserve="all"/>
    7.     <assembly fullname="Unity.Multiplayer.Tools.NetStatsMonitor.Component" preserve="all"/>
    8.     <assembly fullname="Unity.Multiplayer.Tools.NetStatsMonitor.Configuration" preserve="all"/>
    9.     <assembly fullname="Unity.Multiplayer.Tools.NetStatsMonitor.Implementation" preserve="all"/>
    10.     <assembly fullname="Unity.Multiplayer.Tools.NetStatsReporting" preserve="all"/>
    11.     <assembly fullname="Unity.Multiplayer.Tools.NetworkProfiler.Runtime" preserve="all"/>
    12.     <assembly fullname="Unity.Multiplayer.Tools.NetworkSolutionInterface" preserve="all"/>
    13. </linker>
    This link.xml could be more permissive, but let's just first make sure your issue is really the code stripping.

    Please post your findings after testing those suggestions.
     
  6. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    345
    Thanks for the reply. I think that somehow the project ID was getting lost when changing platforms. My latest builds are working.