BeardedManStudios / ForgeNetworkingRemastered

See various forks, also please join the Forge Community fork of Forge Alloy! -> https://github.com/ForgeAlloyCommunity/ForgeAlloy
https://twitter.com/FarrisFaulds
Apache License 2.0
1.49k stars 306 forks source link

Fixed issue for loading/unloading an additive scene multiple times. I… #307

Closed tommohawkaction closed 5 years ago

tommohawkaction commented 5 years ago

Fixed issue for loading/unloading an additive scene multiple times. I've added an example scene which you can enable in the build settings "Master Scene". The example shows how to properly load and unload additive scenes in a network enviroment. You should call Network NetworkManager.Instance.UnloadSceneAdditive(sceneName / sceneIndex). I use this a lot in my game for world streaming so hopefully will also be useful for someone else (Pulled from my custom version of Forge)

tommohawkaction commented 5 years ago

Before this commit the actual behaviour was

[Actual Behaviour] 1) Connect to server which changes the active scene 2) Clients connect to server 3) You load in the additive scene (2 and 3 can be in either order) 4) You unload the additive scene (The client does recieve a command to destory the scene) 5) You load the additive scene (Error the ArgumentException: An element with the same key already exists in the dictionary.)

[New Behaviour] 1) Connect to server which changes the active scene 2) Clients connect to server 3) You load in the additive scene (2 and 3 can be in either order) 4) You unload the additive scene using NetworkManager.Instance.UnloadSceneAdditive, which informs the client to unload the scene aswell as properly disposing of the network objects from the dictionary in the NetWorker 5) Go back to step 3 - All should work

tommohawkaction commented 5 years ago

Looks fine to me and @tommohawkaction said he did test it in a non-custom version of Forge. Only thing being the merge conflicts

Yes all raw Forge. Mentioned this is our private chat, there is an example scene called MasterScene which you can enable in the build settings to see this in action

phalasz commented 5 years ago

Please make sure to use the correct branch for your changes to not get merge conflicts.

tommohawkaction commented 5 years ago

Please make sure to use the correct branch for your changes to not get merge conflicts.

Apologies, are we able to discard most of them except the EditorBuildSettings

phalasz commented 5 years ago

you need to fix your setup. You are using your fork's master branch instead of develop as it is mentioned on the wiki under contributions.

I personally would have created a feature branch from my fork's develop branch and used that instead of adding changes straight to the fork's master/develop branches

Makes it easier to deal with changes from upstream.