NetworkScenePostProcess: removed prefabWarnings HashSet because the extra code is not worth the rare case where we have more than one NetworkIdentity on a prefab. There is no harm in showing a warning for each one.

This commit is contained in:
vis2k 2018-12-30 15:29:45 +01:00
parent b66a5784f1
commit 163600c498

View File

@ -84,8 +84,6 @@ public static int CompareNetworkIdentitySiblingPaths(NetworkIdentity left, Netwo
[PostProcessScene] [PostProcessScene]
public static void OnPostProcessScene() public static void OnPostProcessScene()
{ {
var prefabWarnings = new HashSet<string>();
// vis2k: MISMATCHING SCENEID BUG FIX // vis2k: MISMATCHING SCENEID BUG FIX
// problem: // problem:
// * FindObjectsOfType order is not guaranteed. restarting the // * FindObjectsOfType order is not guaranteed. restarting the
@ -158,12 +156,8 @@ public static void OnPostProcessScene()
GameObject prefabRootGO = PrefabUtility.FindPrefabRoot(prefabGO); GameObject prefabRootGO = PrefabUtility.FindPrefabRoot(prefabGO);
if (prefabRootGO) if (prefabRootGO)
{ {
NetworkIdentity[] identities = prefabRootGO.GetComponentsInChildren<NetworkIdentity>(); if (prefabRootGO.GetComponentsInChildren<NetworkIdentity>().Length > 1)
if (identities.Length > 1 && !prefabWarnings.Contains(prefabRootGO.name))
{ {
// make sure we only print one error per prefab
prefabWarnings.Add(prefabRootGO.name);
Debug.LogWarningFormat("Prefab '{0}' has several NetworkIdentity components attached to itself or its children, this is not supported.", prefabRootGO.name); Debug.LogWarningFormat("Prefab '{0}' has several NetworkIdentity components attached to itself or its children, this is not supported.", prefabRootGO.name);
} }
} }