Skip to content

Commit

Permalink
fix: #652 OnPostProcessScene includes disabled NetworkIdentities in s…
Browse files Browse the repository at this point in the history
…cene
  • Loading branch information
miwarnec committed Apr 4, 2019
1 parent 8caf299 commit ee2ace8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Assets/Mirror/Editor/NetworkScenePostProcess.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.Callbacks;
Expand All @@ -19,7 +20,13 @@ public static void OnPostProcessScene()
// 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(identity => identity.gameObject.scene.name != "DontDestroyOnLoad"))
// => OfTypeAll so disabled objects are included too
IEnumerable<NetworkIdentity> identities = Resources.FindObjectsOfTypeAll<NetworkIdentity>()
.Where(identity => identity.gameObject.hideFlags != HideFlags.NotEditable &&
identity.gameObject.hideFlags != HideFlags.HideAndDontSave &&
identity.gameObject.scene.name != "DontDestroyOnLoad");

foreach (NetworkIdentity identity in identities)
{
// 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 ee2ace8

Please sign in to comment.