Skip to content

Commit 9a5d04b

Browse files
update
Adding same condition define, NGO_FINDOBJECTS_NOSORTING, to the testproject.manualtests assembly define.
1 parent db390f5 commit 9a5d04b

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

testproject/Assets/Tests/Manual/SceneTransitioningAdditive/NetworkManagerMonitor.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
using Unity.Netcode;
22
using UnityEngine;
33

4-
/// <summary>
5-
/// This can be added to the same GameObject the NetworkManager component is assigned to in order to prevent
6-
/// multiple NetworkManager instances from being instantiated if the same scene is loaded.
7-
/// </summary>
8-
public class NetworkManagerMonitor : MonoBehaviour
4+
namespace TestProject.ManualTests
95
{
10-
// Start is called before the first frame update
11-
private void Start()
6+
/// <summary>
7+
/// This can be added to the same GameObject the NetworkManager component is assigned to in order to prevent
8+
/// multiple NetworkManager instances from being instantiated if the same scene is loaded.
9+
/// </summary>
10+
public class NetworkManagerMonitor : MonoBehaviour
1211
{
13-
#if UNITY_6000_4_OR_NEWER
14-
var networkManagerInstances = FindObjectsByType<NetworkManager>();
15-
#else
16-
#if UNITY_2023_1_OR_NEWER
17-
var networkManagerInstances = FindObjectsByType<NetworkManager>(FindObjectsSortMode.None);
12+
// Start is called before the first frame update
13+
private void Start()
14+
{
15+
#if NGO_FINDOBJECTS_NOSORTING
16+
var networkManagerInstances = FindObjectsByType<NetworkManager>();
17+
#elif UNITY_2023_1_OR_NEWER
18+
var networkManagerInstances = FindObjectsByType<NetworkManager>(FindObjectsSortMode.None);
1819
#else
19-
var networkManagerInstances = FindObjectsOfType<NetworkManager>();
20-
#endif
20+
var networkManagerInstances = FindObjectsOfType<NetworkManager>();
2121
#endif
22-
23-
foreach (var instance in networkManagerInstances)
24-
{
25-
if (instance.IsListening)
22+
foreach (var instance in networkManagerInstances)
2623
{
27-
if (gameObject != instance.gameObject)
24+
if (instance.IsListening)
2825
{
29-
var networkManager = GetComponent<NetworkManager>();
30-
Destroy(gameObject);
26+
if (gameObject != instance.gameObject)
27+
{
28+
var networkManager = GetComponent<NetworkManager>();
29+
Destroy(gameObject);
30+
}
3131
}
3232
}
3333
}

testproject/Assets/Tests/Manual/Scripts/NetworkPrefabPool.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,13 @@ private void ShowHideObjectIdLabelClientRpc(bool isVisible)
348348
{
349349
m_LabelEnabled = isVisible;
350350
NetworkObjectLabel.GlobalVisibility = m_LabelEnabled;
351-
#if UNITY_6000_4_OR_NEWER
351+
#if NGO_FINDOBJECTS_NOSORTING
352352
var labels = FindObjectsByType<NetworkObjectLabel>();
353-
#else
354-
#if UNITY_2023_1_OR_NEWER
353+
#elif UNITY_2023_1_OR_NEWER
355354
var labels = FindObjectsByType<NetworkObjectLabel>(FindObjectsSortMode.None);
356355
#else
357356
var labels = FindObjectsOfType<NetworkObjectLabel>();
358357
#endif
359-
#endif
360-
361358
foreach (var label in labels)
362359
{
363360
label.SetLabelVisibility(isVisible);

testproject/Assets/Tests/Manual/testproject.manualtests.asmdef

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@
77
"Unity.Netcode.Components",
88
"Unity.Collections",
99
"Unity.Mathematics"
10-
]
11-
}
10+
],
11+
"versionDefines": [
12+
{
13+
"name": "Unity",
14+
"expression": "6000.4.0b5",
15+
"define": "NGO_FINDOBJECTS_NOSORTING"
16+
}
17+
],
18+
"noEngineReferences": false
19+
}

0 commit comments

Comments
 (0)