Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 437 forks source link

Remotely Downloaded Scenes Via Addressables Cannot Be Used As GameServer #1952

Open CosmicStud opened 2 years ago

CosmicStud commented 2 years ago

Description

I do believe since my gameserver scene is downloaded from the addressables remote location. Not present in the build at all produces this issue. I am developing for Android and Quest. I cannot have a large scene included in the build due to the app stores size limitations. Currently, Netcode blocks scenes not present in the build on the Android platform. Scene Management is enabled. The error happens immediately after StartClient is called, and is present only on the client

I find that the scene path is loaded from the SceneUtility in the NetworkSceneManager script on line 529, throws exception fail otherwise. Addressables scenes are not included in this at all, I do believe, thereby making all scenes that are remotely downloaded unable to be used. How do I fix?

Actual Outcome

Error Unity Exception: Scene Hash 2244099311 does not exist in the HashToBuildIndex table! Verify that all scenes requiring server to client synchronization are in the scenes in build list.

2022/05/09 19:54:34.366 1555 1603 Error Unity Exception: Scene Hash 2244099311 does not exist in the HashToBuildIndex table! Verify that all scenes requiring server to client synchronization are in the scenes in build list. 2022/05/09 19:54:34.366 1555 1603 Error Unity at Unity.Netcode.NetworkSceneManager.ScenePathFromHash (System.UInt32 sceneHash) [0x00027] in /Volumes/SSD1/Source/.../CustomLibrary/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs:533 2022/05/09 19:54:34.366 1555 1603 Error Unity at Unity.Netcode.NetworkSceneManager.SceneNameFromHash (System.UInt32 sceneHash) [0x00012] in /Volumes/SSD1/Source/.../CustomLibrary/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs:519 2022/05/09 19:54:34.366 1555 1603 Error Unity at Unity.Netcode.NetworkSceneManager.HandleSceneEvent (System.UInt64 clientId, Unity.Netcode.FastBufferReader reader) [0x00021] in /Volumes/SSD1/Source/.../CustomLibrary/com.unity.netcode.game

Expected Outcome

Scene loads normally, player starts client sucessfully

Environment

CosmicStud commented 2 years ago

To fix, I had to override the NetworkSceneManager, SceneNameFromHash return value, and hardcode a name :(

lpmaurice commented 2 years ago

Hi @thecosmicstudios , Did you have NGO installed as a package when you built those scenes as Addressables?

CosmicStud commented 2 years ago

@lpmaurice, Hey, yes, installed via package manager. I am using the latest develop up until the date May 9th, 1.0.0.pre.8 . As well as netcode worked before I made the upgrade from 1.0.0.pre.6. Possibly some changes were done that now causes this issue with addressable scenes

WhippetsAintDogs commented 2 years ago

To fix, I had to override the NetworkSceneManager, SceneNameFromHash return value, and hardcode a name :(

@thecosmicstudios Did you use reflection to set your overridden NetworkSceneManager into the SceneManager property (private set) of the NetworkManager component ?

CosmicStud commented 2 years ago

Not at all, I have a fresh copy of Netcode using github, the develop branch, edited the script to just hardcode the scene name at line 520

ashwinimurt commented 2 years ago

Loading scenes from addressables is currently not supported. This is more of a feature request. Thanks for reporting.

NoelStephensUnity commented 2 years ago

@thecosmicstudios As an alternative, would it even be possible to make the larger assets in your scene addressable prefabs? If so, then for non-NetworkObject prefabs it should "just work" and for the addessable network prefabs you could have a networkbehaviour that handles spawning them as needed.