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 311 forks source link

Fix for Unity's Configurable Enter Play Mode #366

Closed mattnewport closed 3 years ago

mattnewport commented 4 years ago

When Unity's experimental Configurable Enter Play Mode (https://docs.unity3d.com/2019.3/Documentation/Manual/ConfigurableEnterPlayMode.html) is enabled static fields are not reinitialized to null.

This change makes Forge compatible with Configurable Enter Play Mode by clearing the static singleton _instance field when the MainThreadManager is destroyed on exiting play mode.

Replaces https://github.com/BeardedManStudios/ForgeNetworkingRemastered/pull/365 which was incorrectly targeted at master branch.