Skip to content

Commit e1e79dc

Browse files
update
Resolving minor issues related to merge.
1 parent 2578615 commit e1e79dc

3 files changed

Lines changed: 41 additions & 19 deletions

File tree

com.unity.netcode.gameobjects/Tests/Runtime/TestHelpers/NetcodeIntegrationTest.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,12 @@ private void InternalOnOneTimeSetup()
639639
/// <returns><see cref="IEnumerator"/></returns>
640640
protected virtual IEnumerator OnSetup()
641641
{
642-
if(m_allPrefabsAsHybrid)
642+
#if UNIFIED_NETCODE
643+
if(m_AllPrefabsAsHybrid)
643644
{
644645
NetworkSpawnManager.RegisterPendingGhost = RegisterPendingGhost;
645646
}
647+
#endif
646648
yield return null;
647649
}
648650

@@ -656,10 +658,12 @@ protected virtual IEnumerator OnSetup()
656658
/// </summary>
657659
protected virtual void OnInlineSetup()
658660
{
659-
if(m_allPrefabsAsHybrid)
661+
#if UNIFIED_NETCODE
662+
if(m_AllPrefabsAsHybrid)
660663
{
661664
NetworkSpawnManager.RegisterPendingGhost = RegisterPendingGhost;
662665
}
666+
#endif
663667
}
664668

665669
/// <summary>
@@ -726,6 +730,7 @@ public IEnumerator SetUp()
726730
VerboseDebug($"Exiting {nameof(SetUp)}");
727731
}
728732

733+
#if UNIFIED_NETCODE
729734
private void RegisterPendingGhost(NetworkObject networkObject, ulong networkObjectId)
730735
{
731736
var ghost = networkObject.GetComponent<GhostAdapter>();
@@ -741,6 +746,7 @@ private void RegisterPendingGhost(NetworkObject networkObject, ulong networkObje
741746
}
742747
Debug.LogError($"Did not find a world for NetworkObject-{networkObjectId}!!");
743748
}
749+
#endif
744750

745751
/// <summary>
746752
/// Override this to add components or adjustments to the default player prefab
@@ -1653,7 +1659,7 @@ protected IEnumerator CoroutineShutdownAndCleanUp()
16531659
protected void UnifiedCleanup()
16541660
{
16551661
#if UNIFIED_NETCODE
1656-
if(m_allPrefabsAsHybrid)
1662+
if(m_AllPrefabsAsHybrid)
16571663
{
16581664
NetworkSpawnManager.RegisterPendingGhost = null;
16591665
CleanupPrefabReferences();
@@ -1818,13 +1824,17 @@ protected void DestroySceneNetworkObjects()
18181824
// and then destroying the ghostAdapter prior to destroying
18191825
// a hybrid prefab.
18201826
var ghostAdapter = networkObject.GetComponent<GhostAdapter>();
1821-
if (ghostAdapter != null && ghostAdapter.prefabReference != null)
1827+
if (ghostAdapter != null)
18221828
{
1823-
var prefabReference = ghostAdapter.prefabReference;
1824-
prefabReference.Prefab = null;
1825-
ghostAdapter.prefabReference = null;
1826-
Object.Destroy(prefabReference);
1827-
Object.Destroy(ghostAdapter);
1829+
if (ghostAdapter.prefabReference != null)
1830+
{
1831+
var prefabReference = ghostAdapter.prefabReference;
1832+
prefabReference.Prefab = null;
1833+
ghostAdapter.prefabReference = null;
1834+
Object.Destroy(prefabReference);
1835+
}
1836+
Object.Destroy(networkObject.gameObject);
1837+
continue;
18281838
}
18291839
#endif
18301840
// Destroy the GameObject that holds the NetworkObject component
@@ -2254,7 +2264,7 @@ internal void WaitForMessagesReceivedWithTimeTravel(List<Type> messagesInOrder,
22542264
}
22552265

22562266
#if UNIFIED_NETCODE
2257-
protected bool m_allPrefabsAsHybrid = false;
2267+
protected bool m_AllPrefabsAsHybrid = false;
22582268
#endif
22592269

22602270
/// <summary>
@@ -2267,7 +2277,7 @@ internal void WaitForMessagesReceivedWithTimeTravel(List<Type> messagesInOrder,
22672277
protected GameObject CreateNetworkObjectPrefab(string baseName)
22682278
{
22692279
#if UNIFIED_NETCODE
2270-
if (m_allPrefabsAsHybrid)
2280+
if (m_AllPrefabsAsHybrid)
22712281
{
22722282
return CreateHybridPrefab(baseName);
22732283
}
@@ -2585,7 +2595,7 @@ private void InitializeTestConfiguration(NetworkTopologyTypes networkTopologyTyp
25852595
}
25862596
#if UNIFIED_NETCODE
25872597
m_UseHost = hostOrServer == HostOrServer.Host || hostOrServer == HostOrServer.DAHost || hostOrServer == HostOrServer.UnifiedHost;
2588-
m_allPrefabsAsHybrid = (hostOrServer == HostOrServer.UnifiedServer || hostOrServer == HostOrServer.UnifiedHost);
2598+
m_AllPrefabsAsHybrid = (hostOrServer == HostOrServer.UnifiedServer || hostOrServer == HostOrServer.UnifiedHost);
25892599
#else
25902600
m_UseHost = hostOrServer == HostOrServer.Host || hostOrServer == HostOrServer.DAHost;
25912601
#endif

testproject/Assets/Tests/Manual/DontDestroyOnLoad/ObjectToNotDestroyBehaviour.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ namespace TestProject.ManualTests
99
/// </summary>
1010
public class ObjectToNotDestroyBehaviour : NetworkBehaviour
1111
{
12+
public static bool VerboseDebug;
13+
1214
private bool m_ContinueSendingPing;
1315
private uint m_PingCounter;
1416

17+
1518
public uint CurrentPing
1619
{
1720
get
@@ -20,12 +23,19 @@ public uint CurrentPing
2023
}
2124
}
2225

23-
/// <summary>
24-
/// When enabled, we move ourself to the DontDestroyOnLoad scene
25-
/// </summary>
26-
private void OnEnable()
26+
private void Log(string msg)
27+
{
28+
if (VerboseDebug)
29+
{
30+
Debug.Log(msg);
31+
}
32+
}
33+
34+
// Migrate into DDOL during pre-spawn
35+
protected override void OnNetworkPreSpawn(ref NetworkManager networkManager)
2736
{
2837
DontDestroyOnLoad(this);
38+
base.OnNetworkPreSpawn(ref networkManager);
2939
}
3040

3141
/// <summary>
@@ -38,11 +48,11 @@ private void PingUpdateClientRpc(uint pingNumber)
3848
{
3949
if (IsHost)
4050
{
41-
Debug.Log($"Sent ping number ({pingNumber}).");
51+
Log($"Sent ping number ({pingNumber}).");
4252
}
4353
else if (IsClient)
4454
{
45-
Debug.Log($"Receiving ping number ({pingNumber}) from server");
55+
Log($"Receiving ping number ({pingNumber}) from server");
4656
m_PingCounter = pingNumber;
4757
}
4858
}

testproject/Assets/Tests/Runtime/RpcObserverTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ private IEnumerator RunRpcObserverTest(List<ulong> nonObservers)
159159
[UnityTest]
160160
public IEnumerator DespawnRespawnObserverTest()
161161
{
162-
if (m_allPrefabsAsHybrid)
162+
#if UNIFIED_NETCODE
163+
if (m_AllPrefabsAsHybrid)
163164
{
164165
Assert.Ignore("Hybrid spawning does not support despawn-without-destroy.");
165166
}
167+
#endif
166168
var nonObservers = new List<ulong>();
167169
m_ServerRpcObserverObject.ResetTest();
168170
// Wait for all clients to report they have spawned an instance of our test prefab

0 commit comments

Comments
 (0)