Problems with Fusion tutorial 102: NetworkSceneManagerDefault not found

I'm learning to use Fusion, and I've started by replicating the basic tutorial. I've done all the setup shown in step 101, but I'm stuck on step 102. When writing BasicSpawner component, it doesn't seem to find NetworkSceneManagerDefault class on StartGame method.

I've created an assembly definition asset to separate my code in an independent assembly definition, and that seems to be the problem. If I move BasicSpawner to Assembly-CSharp (Unity's default assembly), there are no compilation errors. However, this is not a possibility, as working in an independent assembly is one of the foundations of our projects.

The funny thing about this is that this problem does not happen with any other classes which are in the same assembly as this NetworkSceneManagerDefault component.

I would like to know if this is a known issue, or if I'm missing something. Thanks in advance.

Best Answer

  • dani_nexxyo
    edited June 2022 Answer ✓

    [SOLVED]

    I've asked this same question in the official Discord server and I've received a couple of solutions for this problem.

    • Solution 1: Just ignore the line
    SceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>()
    

    in the following code snippet:

    async void StartGame(GameMode mode)
    
           {
    
               // Create the Fusion runner and let it know that we will be providing user input
    
               _runner = gameObject.AddComponent<NetworkRunner>();
    
               _runner.ProvideInput = true;
    
    
    
    
               // Start or join (depends on gamemode) a session with a specific name
    
               await _runner.StartGame(new StartGameArgs()
    
               {
    
                   GameMode = mode,
    
                   SessionName = "TestRoom",
    
                   Scene = SceneManager.GetActiveScene().buildIndex,
    
                   SceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>()
    
               });
    
           }
    
    • Solution 2: Copy and paste NetworkSceneManagerDefault and NetworkSceneManagerBase. It is recommended to put them under a custom namespace to avoid confusion.

    Both solutions work like a charm.


    Bonus track: It is planned to include a Fusion.asmdef file in Fusion 1.2

Answers

  • dani_nexxyo
    edited June 2022 Answer ✓

    [SOLVED]

    I've asked this same question in the official Discord server and I've received a couple of solutions for this problem.

    • Solution 1: Just ignore the line
    SceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>()
    

    in the following code snippet:

    async void StartGame(GameMode mode)
    
           {
    
               // Create the Fusion runner and let it know that we will be providing user input
    
               _runner = gameObject.AddComponent<NetworkRunner>();
    
               _runner.ProvideInput = true;
    
    
    
    
               // Start or join (depends on gamemode) a session with a specific name
    
               await _runner.StartGame(new StartGameArgs()
    
               {
    
                   GameMode = mode,
    
                   SessionName = "TestRoom",
    
                   Scene = SceneManager.GetActiveScene().buildIndex,
    
                   SceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>()
    
               });
    
           }
    
    • Solution 2: Copy and paste NetworkSceneManagerDefault and NetworkSceneManagerBase. It is recommended to put them under a custom namespace to avoid confusion.

    Both solutions work like a charm.


    Bonus track: It is planned to include a Fusion.asmdef file in Fusion 1.2