Skip to content

Commit 570dcb7

Browse files
fix
Wrapping some unified stuff in defines.
1 parent 71a5af5 commit 570dcb7

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,9 +1341,8 @@ private bool CanStart(StartType type)
13411341
return true;
13421342
}
13431343

1344-
public NetcodeWorld NetcodeWorld { get; internal set; }
1345-
13461344
#if UNIFIED_NETCODE
1345+
public NetcodeWorld NetcodeWorld { get; internal set; }
13471346
private System.Collections.IEnumerator WaitForHybridPrefabRegistration(StartType startType)
13481347
{
13491348
if (this == Singleton)

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using System.Runtime.CompilerServices;
77
using System.Text;
88
using NUnit.Framework;
9+
#if UNIFIED_NETCODE
910
using Unity.NetCode;
11+
#endif
1012
using Unity.Netcode.RuntimeTests;
1113
using Unity.Netcode.Transports.UTP;
1214
using UnityEngine;
@@ -1758,6 +1760,7 @@ protected void DestroySceneNetworkObjects()
17581760

17591761
if (CanDestroyNetworkObject(networkObject))
17601762
{
1763+
#if UNIFIED_NETCODE
17611764
// Handle removing the prefab reference and destroying it
17621765
// and then destroying the ghostAdapter prior to destroying
17631766
// a hybrid prefab.
@@ -1770,7 +1773,7 @@ protected void DestroySceneNetworkObjects()
17701773
Object.Destroy(prefabReference);
17711774
Object.Destroy(ghostAdapter);
17721775
}
1773-
1776+
#endif
17741777
// Destroy the GameObject that holds the NetworkObject component
17751778
Object.DestroyImmediate(networkObject.gameObject);
17761779
}
@@ -2387,7 +2390,14 @@ protected void SpawnObjectInstance(NetworkObject networkObjectToSpawn, NetworkMa
23872390
private GameObject SpawnObject(NetworkObject prefabNetworkObject, NetworkManager owner, bool destroyWithScene = false, bool isPlayerObject = false)
23882391
{
23892392
Assert.IsTrue(prefabNetworkObject.GlobalObjectIdHash > 0, $"{nameof(GameObject)} {prefabNetworkObject.name} has a {nameof(NetworkObject.GlobalObjectIdHash)} value of 0! Make sure to make it a valid prefab before trying to spawn!");
2390-
NetCode.Netcode.Instance.m_ActiveWorld = owner.NetcodeWorld;
2393+
#if UNIFIED_NETCODE
2394+
// TODO-FixMe: NetCode.Netcode.Instance is a singleton and might cause issues
2395+
// assigning this.
2396+
if (prefabNetworkObject.HasGhost)
2397+
{
2398+
NetCode.Netcode.Instance.m_ActiveWorld = owner.NetcodeWorld;
2399+
}
2400+
#endif
23912401
var newInstance = Object.Instantiate(prefabNetworkObject.gameObject);
23922402
var networkObjectToSpawn = newInstance.GetComponent<NetworkObject>();
23932403
SpawnObjectInstance(networkObjectToSpawn, owner, destroyWithScene, isPlayerObject);

0 commit comments

Comments
 (0)