Skip to content

Commit

Permalink
fix: #573 (part 1) NetworkScenePostProcess handles NetworkIdentities …
Browse files Browse the repository at this point in the history
…of all scenes except DontDestroyOnLoad. this way it works for additively loaded scenes too.
  • Loading branch information
miwarnec committed Mar 24, 2019
1 parent 603dfa1 commit c1af84e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Assets/Mirror/Editor/NetworkScenePostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ public class NetworkScenePostProcess : MonoBehaviour
[PostProcessScene]
public static void OnPostProcessScene()
{
// find all NetworkIdentities in this scene
// => but really only from this scene. this avoids weird situations
// find all NetworkIdentities in all scenes
// => can't limit it to GetActiveScene() because that wouldn't work
// for additive scene loads (the additively loaded scene is never
// the active scene)
// => ignore DontDestroyOnLoad scene! this avoids weird situations
// like in NetworkZones when we destroy the local player and
// load another scene afterwards, yet the local player is still
// in the FindObjectsOfType result with scene=DontDestroyOnLoad
// for some reason
foreach (NetworkIdentity identity in FindObjectsOfType<NetworkIdentity>().Where(InActiveScene))
foreach (NetworkIdentity identity in FindObjectsOfType<NetworkIdentity>().Where(identity => identity.gameObject.scene.name != "DontDestroyOnLoad"))
{
// if we had a [ConflictComponent] attribute that would be better than this check.
// also there is no context about which scene this is in.
Expand Down

0 comments on commit c1af84e

Please sign in to comment.